package com.beiye.drivertransport.SubActivity;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Camera;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.android.frame.http.HttpListener;
import com.android.frame.view.linearlistview.LinearListView;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.Video.JZMediaIjk;
import com.beiye.drivertransport.Video.MyJZVideoPlayerStandard;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.adapter.CourseDetailRvSubjectApt;
import com.beiye.drivertransport.adapter.CourseDetailSubjectApt;
import com.beiye.drivertransport.bean.CheckBean;
import com.beiye.drivertransport.bean.CourseDetailBean;
import com.beiye.drivertransport.bean.CourseDetailSubjectBean;
import com.beiye.drivertransport.bean.LearnthematiclearningBean;
import com.beiye.drivertransport.bean.LoginUserBean;
import com.beiye.drivertransport.bean.MineUseBean;
import com.beiye.drivertransport.bean.SignBean;
import com.beiye.drivertransport.bean.SpecifiedPhotoBean;
import com.beiye.drivertransport.bean.UserTcPhoto;
import com.beiye.drivertransport.config.AppInterfaceConfig;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.safelearn.SubSpecifiedLearningHomeActivity;
import com.beiye.drivertransport.thirdparty.tbs.SuperFileView2;
import com.beiye.drivertransport.utils.FileParseUtil;
import com.beiye.drivertransport.utils.HelpUtil;
import com.beiye.drivertransport.utils.LogUtils;
import com.beiye.drivertransport.utils.MessageEvent;
import com.beiye.drivertransport.utils.MusicUtils;
import com.beiye.drivertransport.utils.TiShiDialog;
import com.beiye.drivertransport.utils.UserManger;
import com.beiye.drivertransport.utils.Utils;
import com.beiye.drivertransport.view.CircularProgressView;
import com.beiye.drivertransport.view.LiumRadioGroup;
import com.githang.statusbar.StatusBarCompat;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.picasso.Picasso;

import net.frakbot.jumpingbeans.JumpingBeans;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;


import butterknife.OnClick;
import cn.jzvd.JZDataSource;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;
import es.dmoral.toasty.Toasty;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

//专项培训课程学习界面
public class LearnthemticlearningDetailsActivity extends TwoBaseAty implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener {


    WebView web;

    LinearLayout le_parement;


    ImageView img_Courseback;

    ImageView img_course2;

    RecyclerView lv_coursedetail;

    MyJZVideoPlayerStandard jcVideoPlayerStandard;

    TextView tv_courseName;

    TextView tv_courseLength;

    TextView tv_cumulativeLength;//累计时长

    ImageView show_camera_iv;//显示照片

    ImageView show_camera_iv1;//显示照片第二张

    ImageView show_camera_iv2;//显示照片第三张

    ImageView show_camera_iv3;//显示照片第四张

    ImageView show_camera_iv4;//显示照片第五张
    //    @Bind(R.id.id_area_sv)
//    SurfaceView surfaceSv;//预览照片

    TextView tv_sure;//提交

    TextView tv_save;//中途保存

    RelativeLayout re_course;//隐藏按钮

    LinearLayout re_course1;//照片布局

    LinearLayout le_course1;//隐藏照片

    TextView img_course;

    TextView tv_course11;//请回答

    RelativeLayout re_course2;//隐藏语音

    ImageView playOrPauseFab;//播放

    SeekBar musicSeekBar;//

    TextView tv_playorpause;//播放与暂停显示

    TextView progress_tv;//播放进度时间

    TextView total_tv;//播放总时间

    ScrollView scroll_view;
    private MediaPlayer mediaPlayer;
    private MusicHandler musicHandler;
    private AlertDialog mDialog;
    private TextView mOffTextView;
    private static final String TAG = LearnthemticlearningDetailsActivity.class.getSimpleName();
    private static final int MEDIA_TYPE_IMAGE = 1;
    private Timer mOffTime;
    private boolean ishave = false;
    private boolean isloob = true;
    private TimerTask timerTask;


    SuperFileView2 mSuperFileView;
    private JumpingBeans jumpingBeans2;
    private PopupWindow mDownloadPopWindow;

    private String forbidHour="23,6";

    private Handler mOffHandler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what > 0) {
                ////动态显示倒计时
                downtime.setText(msg.what + "");
            } else {
                ////倒计时结束自动关闭
                if (mPopWindow != null) {
                    downtime.setVisibility(View.GONE);
                    tv_photo.setText("请拍照，继续学习！");
                    tv_photo4.setVisibility(View.GONE);
                    tv_photo1.setText("你未在规定时间内操作");
                    tv_photo.setTextColor(Color.parseColor("#ff8092"));
                    tv_photo2.setVisibility(View.GONE);
                    img_photo.setImageResource(R.mipmap.sorry);
                    //   mPopWindow.dismiss();
                    //  timerTask.cancel();
                    resave();//自动保存
                }

                // off();////关闭后的操作
                mOffTime.cancel();
            }
            super.handleMessage(msg);
        }
    };

    private int formattimecnt;
    Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            int what = msg.what;
            if (what == 0) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int uschSn = sp1.getInt("uschSn", 0);
                String format = sp1.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp.getInt("tcsn", 0);
                                    int uschSn = sp.getInt("uschSn", 0);
                                    int firsttime = sp.getInt("intfirsttime" + tcsn, 0);
                                    String firsttimestr = getStringTime(firsttime);
                                    SharedPreferences.Editor edit = sp.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime1" + tcsn, firsttimestr);
                                    edit.commit();
                                    // String duration = sp.getString("duration", "");

                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr);
                                    //       LogUtils.e("duration", duration);

                                    if (stringTime.equals(firsttimestr)) {

                                        timerTask.cancel();
                                        initDialog();
//                                        JZVideoPlayer jzvd = JZVideoPlayerManager.getCurrentJzvd();
//                                        if(jzvd!=null) {
//                                            jzvd.onStatePause();
//                                            JZMediaManager.pause();//暂停
//                                        }

                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);

                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int firsttime2 = sp1.getInt("intfirsttime2" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String firsttimestr2 = getStringTime(firsttime2);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    LogUtils.e("第一次验证", firsttimestr2);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();
                                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                                    if (imgurl.equals("")) {
                                        if (numTime == firsttime) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        } else if (numTime == firsttime2) {
                                            edit.putString("firsttime" + tcsn, firsttimestr2);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        int courseLengthtime = courseLength * 60;
                                        // String courseLengthtime1 = getStringTime(courseLengthtime);
                                        LogUtils.e("退出拍照后计时", stringTime);
                                        if (numTime >= courseLengthtime && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLengthtime);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            if (rowscourseList.size() != 0) {
                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int uschSn2 = sp2.getInt("uschSn", 0);
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                            int sn = sp2.getInt("sn", 0);
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setSnapTime(firsttimesub);
                                            userTcPhoto.setUrl(imgurl1);
                                            photoList.add(userTcPhoto);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                        }
//                                            else{
//                                                //无题情况无照片
//                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                                String userId1 = userInfo1.getData().getUserId();
//                                                SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                        Context.MODE_PRIVATE);
//                                                int tcsn2 = sp2.getInt("tcsn", 0);
//                                                int uschSn2 = sp2.getInt("uschSn", 0);
//                                                String imgurl1 = sp2.getString("imgurl"+ tcsn2+uschSn2, "");
//                                                int sn = sp2.getInt("sn", 0);
//                                                String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
//                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                                   String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                                userTcPhoto.setSnapTime(firsttimesub);
//                                                userTcPhoto.setUrl(imgurl1);
//                                                photoList.add(userTcPhoto);
//                                                Gson gson = new Gson();
//                                                String strphotoList = gson.toJson(photoList);
//                                                LogUtils.e("strphotoList", strphotoList);
//                                                initsuredata(uschSn2,sn,tcsn2,courseLength,photoList);
//                                            }
//
//
//
//
//                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }

            }
//            else if (what == 1) {
//                WebSettings settings = web.getSettings();
//                // 允许使用脚本语言
//                settings.setJavaScriptEnabled(true);
//                // 支持缩放
//                settings.setSupportZoom(true);
//                //  mWebView.addJavascriptInterface(new JavaScriptinterface(BannerItemAty.this), "android");
//                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
//                    settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
//                }//Android 5.0中使用webView 加载网页不显示图片问题
//
//                // 在当前应用加载网页(直接加载网页不经过浏览器）
//                web.setWebViewClient(new WebViewClient() {
//                    @Override // 开始加载网页时触发
//                    public void onPageStarted(WebView view, String url, Bitmap favicon) {
//                        super.onPageStarted(view, url, favicon);
//
//                    }
//
//                    @Override // 网页加载完成之后触发
//                    public void onPageFinished(WebView view, String url) {
//
//                        super.onPageFinished(view, url);
//
//                    }
//                });
//                LoginUserBean userInfo = UserManger.getUserInfo();
//                String userId = userInfo.getData().getUserId();
//                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity"+userId,
//                        Context.MODE_PRIVATE);
//                int tcsn = sp.getInt("tcsn", 0);
//                web.loadUrl(AppInterfaceConfig.BASE_URL + "app/course/content?" + "sn=" + tcsn);
//
//                // 显示进度
//                web.setWebChromeClient(new WebChromeClient() {
//                    @Override // 加载网页进度改变时触发
//                    public void onProgressChanged(WebView view, int newProgress) {
//
//                        super.onProgressChanged(view, newProgress);
//                    }
//                });
//            }
            else if (what == 2) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp1.getInt("tcsn", 0);
                int uschSn = sp1.getInt("uschSn", 0);
                String format = sp1.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 1;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LogUtils.e("format", stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.commit();
                                    int courseLength = sp1.getInt("courseLength", 0);
                                    int courseLengthtime = courseLength * 60;
                                    String courseLengthtime1 = getStringTime(courseLengthtime);
                                    if (stringTime.equals(courseLengthtime1)) {
                                        timerTask.cancel();
                                        tv_cumulativeLength.setText(courseLengthtime1);
                                        if (rowscourseList.size() != 0) {
                                            for (int i = 0; i < rowscourseList.size(); i++) {
                                                if (rowscourseList.get(i).isSelect() == false) {
                                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                    builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                    builder1.setTitle("提示:");
                                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                            dialog.dismiss();
                                                            //设置你的操作事项
                                                        }
                                                    });

                                                    builder1.create().show();
                                                    return;
                                                } else {

                                                    if (rowscourseList.get(i).isLOOP() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });
                                                        builder1.create().show();

                                                        return;
                                                    }
                                                }
                                            }
                                        }

                                        //有题无照片
                                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                                        String userId1 = userInfo1.getData().getUserId();
                                        SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                Context.MODE_PRIVATE);
                                        int tcsn2 = sp2.getInt("tcsn", 0);
                                        int uschSn2 = sp2.getInt("uschSn", 0);
                                        String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                        int sn = sp2.getInt("sn", 0);
                                        String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                        //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                                        userTcPhoto.setSnapTime(firsttime);
                                        userTcPhoto.setUrl(imgurl);
                                        photoList.add(userTcPhoto);
                                        Gson gson = new Gson();
                                        String strphotoList = gson.toJson(photoList);
                                        LogUtils.e("strphotoList", strphotoList);
                                        initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                    }
//                                        else{
//                                            //无题情况无照片
//                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                            String userId1 = userInfo1.getData().getUserId();
//                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                    Context.MODE_PRIVATE);
//                                            int tcsn2 = sp2.getInt("tcsn", 0);
//                                            int uschSn2 = sp2.getInt("uschSn", 0);
//                                            String imgurl = sp2.getString("imgurl"+ tcsn2+uschSn2, "");
//                                            int sn = sp2.getInt("sn", 0);
//                                            String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
//                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                            //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                            userTcPhoto.setSnapTime(firsttime);
//                                            userTcPhoto.setUrl(imgurl);
//                                            photoList.add(userTcPhoto);
//                                            Gson gson = new Gson();
//                                            String strphotoList = gson.toJson(photoList);
//                                            LogUtils.e("strphotoList", strphotoList);
//                                            initsuredata(uschSn2,sn,tcsn2,courseLength,photoList);
//                                        }
//                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(formattimecnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LogUtils.e("format", stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.commit();
                                    int courseLength = sp1.getInt("courseLength", 0);
                                    int courseLengthtime = courseLength * 60;
                                    String courseLengthtime1 = getStringTime(courseLengthtime);
                                    if (stringTime.equals(courseLengthtime1)) {
                                        tv_cumulativeLength.setText(courseLengthtime1);
                                        timerTask.cancel();
                                        //自动提交
                                        if (rowscourseList.size() != 0) {
                                            for (int i = 0; i < rowscourseList.size(); i++) {
                                                if (rowscourseList.get(i).isSelect() == false) {
                                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                    builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                    builder1.setTitle("提示:");
                                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                            dialog.dismiss();
                                                            //设置你的操作事项
                                                        }
                                                    });

                                                    builder1.create().show();
                                                    return;
                                                } else {

                                                    if (rowscourseList.get(i).isLOOP() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });
                                                        builder1.create().show();

                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        //有题无照片
                                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                                        String userId1 = userInfo1.getData().getUserId();
                                        SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                Context.MODE_PRIVATE);
                                        int tcsn2 = sp2.getInt("tcsn", 0);
                                        int uschSn2 = sp2.getInt("uschSn", 0);
                                        String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                        int sn = sp2.getInt("sn", 0);
                                        String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                        //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                                        userTcPhoto.setSnapTime(firsttime);
                                        userTcPhoto.setUrl(imgurl);
                                        photoList.add(userTcPhoto);
                                        Gson gson = new Gson();
                                        String strphotoList = gson.toJson(photoList);
                                        LogUtils.e("strphotoList", strphotoList);
                                        initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                    }
//                                        else{
//                                            //无题情况无照片
//                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                            String userId1 = userInfo1.getData().getUserId();
//                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                    Context.MODE_PRIVATE);
//                                            int tcsn2 = sp2.getInt("tcsn", 0);
//                                            int uschSn2 = sp2.getInt("uschSn", 0);
//                                            String imgurl = sp2.getString("imgurl"+ tcsn2+uschSn2, "");
//                                            int sn = sp2.getInt("sn", 0);
//                                            String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
//                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                            //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                            userTcPhoto.setSnapTime(firsttime);
//                                            userTcPhoto.setUrl(imgurl);
//                                            photoList.add(userTcPhoto);
//                                            Gson gson = new Gson();
//                                            String strphotoList = gson.toJson(photoList);
//                                            LogUtils.e("strphotoList", strphotoList);
//                                            initsuredata(uschSn2,sn,tcsn2,courseLength,photoList);
//                                        }
                                    //                                   }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 3) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                String format = sp.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();

                                    if (stringTime.equals(firsttimestr1)) {

                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
//                                    int firsttime2 = sp1.getInt("intfirsttime2" + otcSn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }
                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }
                                    } else {
                                        int courseLength = sp1.getInt("courseLength", 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + courseLength * 60);
//                                        String[] splitformat = stringTime.split(":");
//                                        String format1 = splitformat[0];
//                                        String format2 = splitformat[1];
//                                        String format3 = splitformat[2];
//                                        int iformat1 = Integer.valueOf(format1);//转int
//                                        int iformat2 = Integer.valueOf(format2);//转int
//                                        int iformat3 = Integer.valueOf(format3);//转int
//                                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                        if(formattime==courseLength*60) {
//                                            timerTask.cancel();
//                                        }
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            timerTask.cancel();
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            //自动提交
                                            if (rowscourseList.size() != 0) {//判断是否有题

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int uschSn2 = sp2.getInt("uschSn", 0);
                                            int sn = sp2.getInt("sn", 0);
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                            String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                                            if (imgurl1.equals("")) {
                                                initDialog();
                                                return;
                                            }
                                            if (imgurl2.equals("")) {
                                                initDialog3();
                                                return;
                                            }

                                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00

                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimesub);
                                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                            userTcPhoto1.setUrl(imgurl2);
                                            userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                                            photoList.add(userTcPhoto);
                                            photoList.add(userTcPhoto1);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 4) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                String format = sp.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();
                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }

                                    } else if (numTime == numsecondpart) {
                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }
                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + courseLength * 60);
//                                        String[] splitformat = stringTime.split(":");
//                                        String format1 = splitformat[0];
//                                        String format2 = splitformat[1];
//                                        String format3 = splitformat[2];
//                                        int iformat1 = Integer.valueOf(format1);//转int
//                                        int iformat2 = Integer.valueOf(format2);//转int
//                                        int iformat3 = Integer.valueOf(format3);//转int
//                                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                        if(formattime==courseLength*60) {
//                                            timerTask.cancel();
//                                        }
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }

                                            }
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int uschSn2 = sp2.getInt("uschSn", 0);
                                            int sn = sp2.getInt("sn", 0);
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                            String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                            String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                                            String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                                            if (imgurl1.equals("")) {
                                                initDialog();
                                                return;
                                            }
                                            if (imgurl2.equals("")) {
                                                initDialog3();
                                                return;
                                            }
                                            if (imgurl3.equals("")) {
                                                initDialog4();
                                                return;
                                            }

                                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimesub);
                                            photoList.add(userTcPhoto);
                                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                            userTcPhoto1.setUrl(imgurl2);
                                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                            photoList.add(userTcPhoto1);
                                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                            userTcPhoto2.setUrl(imgurl3);
                                            userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                                            photoList.add(userTcPhoto2);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                        }
//                                            else{//无题有照片自动提交
//                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                                String userId1 = userInfo1.getData().getUserId();
//                                                SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                        Context.MODE_PRIVATE);
//                                                int tcsn2 = sp2.getInt("tcsn", 0);
//                                                int sn2 = sp2.getInt("sn", 0);
//                                                String orgId2 = sp2.getString("orgId", "");
//                                                int otcSn2 = sp2.getInt("otcSn", 0);
//                                                int learnsn2 = sp2.getInt("learnsn", 0);
//                                                String firsttimestr = sp2.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + otcSn2, "");//第三次抓拍时间
//                                                String imgurl1 = sp2.getString("imgurl" + otcSn2 + learnsn2, "");
//                                                String imgurl2 = sp2.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                                String imgurl3 = sp2.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                                if(imgurl1.equals(""))
//                                                {
//                                                    initDialog();
//                                                    return;
//                                                }
//                                                if(imgurl2.equals(""))
//                                                {
//                                                    initDialog3();
//                                                    return;
//                                                }
//                                                if(imgurl3.equals(""))
//                                                {
//                                                    initDialog4();
//                                                    return;
//                                                }
//                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//
//                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                                userTcPhoto.setUrl(imgurl1);
//                                                userTcPhoto.setSnapTime(firsttimesub);
//                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                                userTcPhoto1.setUrl(imgurl2);
//                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
//                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                                userTcPhoto2.setUrl(imgurl3);
//                                                userTcPhoto2.setSnapTime(numFifthpartstr1sub);
//                                                photoList.add(userTcPhoto);
//                                                photoList.add(userTcPhoto1);
//                                                photoList.add(userTcPhoto2);
//                                                Gson gson = new Gson();
//                                                String strphotoList = gson.toJson(photoList);
//                                                LogUtils.e("strphotoList", strphotoList);
//                                                initsuredata(sn2, userId1, orgId2, tcsn2, otcSn2, learnsn2, courseLength, photoList);
//                                            }
//                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 5) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                String format = sp.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();
                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }
                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numthirdpartstr = getStringTime(numthirdpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numthirdpartstr);
                                    LogUtils.e("第四次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }

                                    } else if (numTime == numsecondpart) {

                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }

                                    } else if (numTime == numthirdpart) {

                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }

                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog5();
                                        }
                                    } else {

                                        int courseLength = sp1.getInt("courseLength", 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + courseLength * 60);
//                                        String[] splitformat = stringTime.split(":");
//                                        String format1 = splitformat[0];
//                                        String format2 = splitformat[1];
//                                        String format3 = splitformat[2];
//                                        int iformat1 = Integer.valueOf(format1);//转int
//                                        int iformat2 = Integer.valueOf(format2);//转int
//                                        int iformat3 = Integer.valueOf(format3);//转int
//                                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                        if(formattime==courseLength*60) {
//                                            timerTask.cancel();
//                                        }
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }

                                            }
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int uschSn2 = sp2.getInt("uschSn", 0);
                                            int sn = sp2.getInt("sn", 0);
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                            String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                            String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                            String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                                            String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                                            String imgurl4 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                                            if (imgurl1.equals("")) {
                                                initDialog();
                                                return;
                                            }
                                            if (imgurl2.equals("")) {
                                                initDialog3();
                                                return;
                                            }
                                            if (imgurl3.equals("")) {
                                                initDialog4();
                                                return;
                                            }
                                            if (imgurl4.equals("")) {
                                                initDialog5();
                                                return;
                                            }

                                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numthirdpartstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimesub);
                                            photoList.add(userTcPhoto);
                                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                            userTcPhoto1.setUrl(imgurl2);
                                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                            photoList.add(userTcPhoto1);
                                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                            userTcPhoto2.setUrl(imgurl3);
                                            userTcPhoto2.setSnapTime(numthirdpartstr1sub);
                                            photoList.add(userTcPhoto2);
                                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                            userTcPhoto3.setUrl(imgurl4);
                                            userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                                            photoList.add(userTcPhoto3);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                        }
//                                            else{//无题有照片自动提交
//                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                                String userId1 = userInfo1.getData().getUserId();
//                                                SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                        Context.MODE_PRIVATE);
//                                                int tcsn2 = sp2.getInt("tcsn", 0);
//                                                int sn2 = sp2.getInt("sn", 0);
//                                                String orgId2 = sp2.getString("orgId", "");
//                                                int otcSn2 = sp2.getInt("otcSn", 0);
//                                                int learnsn2 = sp2.getInt("learnsn", 0);
//                                                String firsttimestr = sp2.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + otcSn2, "");//第三次抓拍时间
//                                                String imgurl1 = sp2.getString("imgurl" + otcSn2 + learnsn2, "");
//                                                String imgurl2 = sp2.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                                String imgurl3 = sp2.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                                if(imgurl1.equals(""))
//                                                {
//                                                    initDialog();
//                                                    return;
//                                                }
//                                                if(imgurl2.equals(""))
//                                                {
//                                                    initDialog3();
//                                                    return;
//                                                }
//                                                if(imgurl3.equals(""))
//                                                {
//                                                    initDialog4();
//                                                    return;
//                                                }
//                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//
//                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                                userTcPhoto.setUrl(imgurl1);
//                                                userTcPhoto.setSnapTime(firsttimesub);
//                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                                userTcPhoto1.setUrl(imgurl2);
//                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
//                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                                userTcPhoto2.setUrl(imgurl3);
//                                                userTcPhoto2.setSnapTime(numFifthpartstr1sub);
//                                                photoList.add(userTcPhoto);
//                                                photoList.add(userTcPhoto1);
//                                                photoList.add(userTcPhoto2);
//                                                Gson gson = new Gson();
//                                                String strphotoList = gson.toJson(photoList);
//                                                LogUtils.e("strphotoList", strphotoList);
//                                                initsuredata(sn2, userId1, orgId2, tcsn2, otcSn2, learnsn2, courseLength, photoList);
//                                            }
//                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            } else if (what == 6) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                String format = sp.getString("format" + tcsn + uschSn, "");
                if (format.equals("")) {
                    timerTask = new TimerTask() {
                        int cnt = 0;

                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String stringTime = getStringTime(cnt++);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次", firsttimestr1);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.commit();
                                    if (stringTime.equals(firsttimestr1)) {
                                        timerTask.cancel();
                                        initDialog();
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                } else {
                    String[] splitformat = format.split(":");
                    String format1 = splitformat[0];
                    String format2 = splitformat[1];
                    String format3 = splitformat[2];
                    int iformat1 = Integer.valueOf(format1);//转int
                    int iformat2 = Integer.valueOf(format2);//转int
                    int iformat3 = Integer.valueOf(format3);//转int
                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                    formattimecnt = formattime;
                    timerTask = new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    int numTime = formattimecnt++;
                                    String stringTime = getStringTime(numTime);
                                    tv_cumulativeLength.setText(stringTime);
                                    LoginUserBean userInfo = UserManger.getUserInfo();
                                    String userId = userInfo.getData().getUserId();
                                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                            Context.MODE_PRIVATE);
                                    int tcsn = sp1.getInt("tcsn", 0);
                                    int uschSn = sp1.getInt("uschSn", 0);
                                    int firsttime = sp1.getInt("intfirsttime" + tcsn, 0);
                                    int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                                    int numthirdpart = sp1.getInt("numthirdpart" + tcsn, 0);
                                    int numfourpart = sp1.getInt("numfourpart" + tcsn, 0);
                                    int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                                    int minPer = sp1.getInt("minPer", 0);
                                    String firsttimestr1 = getStringTime(firsttime);
                                    String numsecondpartstr = getStringTime(numsecondpart);
                                    String numthirdpartstr = getStringTime(numthirdpart);
                                    String numfourpartstr = getStringTime(numfourpart);
                                    String numFifthpartstr = getStringTime(numFifthpart);
                                    LogUtils.e("计时", stringTime);
                                    LogUtils.e("第一次验证", firsttimestr1);
                                    LogUtils.e("第二次", numsecondpartstr);
                                    LogUtils.e("第三次", numthirdpartstr);
                                    LogUtils.e("第四次", numfourpartstr);
                                    LogUtils.e("第五次", numFifthpartstr);
                                    SharedPreferences.Editor edit = sp1.edit();
                                    edit.putString("format" + tcsn + uschSn, stringTime);
                                    edit.putString("firsttime" + tcsn, firsttimestr1);
                                    edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                    edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                    edit.putString("numfourpartstr" + tcsn, numfourpartstr);
                                    edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                    edit.commit();
//                                    String imgurl = sp1.getString("imgurl" + otcSn+learnsn, "");
                                    if (numTime == firsttime) {
                                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("firsttime" + tcsn, firsttimestr1);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog();
                                        }
                                    } else if (numTime == numsecondpart) {

                                        if (show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numsecondpartstr" + tcsn, numsecondpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog3();
                                        }

                                    } else if (numTime == numthirdpart) {
                                        if (show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numthirdpartstr" + tcsn, numthirdpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog4();
                                        }
                                    } else if (numTime == numfourpart) {
                                        if (show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numfourpartstr" + tcsn, numfourpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog5();
                                        }
                                    } else if (numTime == numFifthpart) {
                                        if (show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                                            edit.putString("numFifthpartstr" + tcsn, numFifthpartstr);
                                            edit.commit();
                                            timerTask.cancel();
                                            initDialog6();
                                        }
                                    } else {
                                        int courseLength = sp1.getInt("courseLength", 0);
                                        LogUtils.e("退出拍照后计时", stringTime + "/" + courseLength * 60);
//                                        String[] splitformat = stringTime.split(":");
//                                        String format1 = splitformat[0];
//                                        String format2 = splitformat[1];
//                                        String format3 = splitformat[2];
//                                        int iformat1 = Integer.valueOf(format1);//转int
//                                        int iformat2 = Integer.valueOf(format2);//转int
//                                        int iformat3 = Integer.valueOf(format3);//转int
//                                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                                        if(formattime==courseLength*60) {
//                                            timerTask.cancel();
//                                        }
                                        if (numTime >= courseLength * 60 && courseLength != 0) {
                                            String courseLengthstr = getStringTime(courseLength * 60);
                                            tv_cumulativeLength.setText(courseLengthstr);
                                            timerTask.cancel();
                                            //自动提交
                                            if (rowscourseList.size() != 0) {

                                                for (int i = 0; i < rowscourseList.size(); i++) {
                                                    if (rowscourseList.get(i).isSelect() == false) {
                                                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                        builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                                        builder1.setTitle("提示:");
                                                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                            public void onClick(DialogInterface dialog, int which) {
                                                                dialog.dismiss();
                                                                //设置你的操作事项
                                                            }
                                                        });

                                                        builder1.create().show();
                                                        return;
                                                    } else {

                                                        if (rowscourseList.get(i).isLOOP() == false) {
                                                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                                                            builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                                            builder1.setTitle("提示:");
                                                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                                                public void onClick(DialogInterface dialog, int which) {
                                                                    dialog.dismiss();
                                                                    //设置你的操作事项
                                                                }
                                                            });
                                                            builder1.create().show();

                                                            return;
                                                        }
                                                    }
                                                }

                                            }
                                            LoginUserBean userInfo1 = UserManger.getUserInfo();
                                            String userId1 = userInfo1.getData().getUserId();
                                            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                                    Context.MODE_PRIVATE);
                                            int tcsn2 = sp2.getInt("tcsn", 0);
                                            int uschSn2 = sp2.getInt("uschSn", 0);
                                            int sn = sp2.getInt("sn", 0);
                                            String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                                            String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                                            String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                                            String numfourpartstr1 = sp2.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                                            String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                                            String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                                            String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                                            String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                                            String imgurl4 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                                            String imgurl5 = sp2.getString("imgurl4" + tcsn2 + uschSn2, "");
                                            if (imgurl1.equals("")) {
                                                initDialog();
                                                return;
                                            }
                                            if (imgurl2.equals("")) {
                                                initDialog3();
                                                return;
                                            }
                                            if (imgurl3.equals("")) {
                                                initDialog4();
                                                return;
                                            }
                                            if (imgurl4.equals("")) {
                                                initDialog5();
                                                return;
                                            }
                                            if (imgurl5.equals("")) {
                                                initDialog6();
                                                return;
                                            }

                                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numthirdpartstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                                            userTcPhoto.setUrl(imgurl1);
                                            userTcPhoto.setSnapTime(firsttimesub);
                                            photoList.add(userTcPhoto);
                                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                            userTcPhoto1.setUrl(imgurl2);
                                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                            photoList.add(userTcPhoto1);
                                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                            userTcPhoto2.setUrl(imgurl3);
                                            userTcPhoto2.setSnapTime(numthirdpartstr1sub);
                                            photoList.add(userTcPhoto2);
                                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                            userTcPhoto3.setUrl(imgurl4);
                                            userTcPhoto3.setSnapTime(numfourpartstr1sub);
                                            photoList.add(userTcPhoto3);
                                            UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                                            userTcPhoto4.setUrl(imgurl5);
                                            userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                                            photoList.add(userTcPhoto4);
                                            Gson gson = new Gson();
                                            String strphotoList = gson.toJson(photoList);
                                            LogUtils.e("strphotoList", strphotoList);
                                            initsuredata(uschSn2, sn, tcsn2, courseLength, photoList);
                                        }
//                                            else{//无题有照片自动提交
//                                                LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                                String userId1 = userInfo1.getData().getUserId();
//                                                SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
//                                                        Context.MODE_PRIVATE);
//                                                int tcsn2 = sp2.getInt("tcsn", 0);
//                                                int sn2 = sp2.getInt("sn", 0);
//                                                String orgId2 = sp2.getString("orgId", "");
//                                                int otcSn2 = sp2.getInt("otcSn", 0);
//                                                int learnsn2 = sp2.getInt("learnsn", 0);
//                                                String firsttimestr = sp2.getString("firsttime" + otcSn2, "");//第一次抓拍时间
//                                                String numsecondpartstr1 = sp2.getString("numsecondpartstr" + otcSn2, "");//第二次抓拍时间
//                                                String numFifthpartstr1 = sp2.getString("numFifthpartstr" + otcSn2, "");//第三次抓拍时间
//                                                String imgurl1 = sp2.getString("imgurl" + otcSn2 + learnsn2, "");
//                                                String imgurl2 = sp2.getString("imgurl1" + otcSn2 + learnsn2, "");
//                                                String imgurl3 = sp2.getString("imgurl2" + otcSn2 + learnsn2, "");
//                                                if(imgurl1.equals(""))
//                                                {
//                                                    initDialog();
//                                                    return;
//                                                }
//                                                if(imgurl2.equals(""))
//                                                {
//                                                    initDialog3();
//                                                    return;
//                                                }
//                                                if(imgurl3.equals(""))
//                                                {
//                                                    initDialog4();
//                                                    return;
//                                                }
//                                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numsecondpartstrsub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//                                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
//
//                                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                                                UserTcPhoto userTcPhoto = new UserTcPhoto();
//                                                userTcPhoto.setUrl(imgurl1);
//                                                userTcPhoto.setSnapTime(firsttimesub);
//                                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
//                                                userTcPhoto1.setUrl(imgurl2);
//                                                userTcPhoto1.setSnapTime(numsecondpartstrsub);
//                                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
//                                                userTcPhoto2.setUrl(imgurl3);
//                                                userTcPhoto2.setSnapTime(numFifthpartstr1sub);
//                                                photoList.add(userTcPhoto);
//                                                photoList.add(userTcPhoto1);
//                                                photoList.add(userTcPhoto2);
//                                                Gson gson = new Gson();
//                                                String strphotoList = gson.toJson(photoList);
//                                                LogUtils.e("strphotoList", strphotoList);
//                                                initsuredata(sn2, userId1, orgId2, tcsn2, otcSn2, learnsn2, courseLength, photoList);
//                                            }
//                                        }
                                    }

                                }
                            });
                        }
                    };
                    timer1.schedule(timerTask, 0, 1000);
                }
            }
        }
    };
    private CourseDetailRvSubjectApt courseDetailSubjectApt;
    private Camera mCamera;
    private SurfaceHolder mHolder;
    private PopupWindow mPopWindow;
    private long rangeTime;
    private FileInputStream fStream;
    private ArrayList<CourseDetailSubjectBean.RowsBean> rowscourseList = new ArrayList<>();
    private Timer timer1;
    private int subformatTurnSecond;
    private SensorManager sensorManager;
    private Jzvd.JZAutoFullscreenListener sensorEventListener;
    private TextView downtime;
    private PopupWindow mSorryPopWindow;
    private ProgressDialog mProgressDialog;
    private PopupWindow mPopWindow2;
    private PopupWindow mStopPopWindow;
    private TextView tv_photo2;
    private TextView tv_photo4;
    private TextView tv_photo1;
    private TextView tv_photo;
    private ImageView img_photo;
    private Animation animation;
    private int stId;
    private String mac;


    @Override
    public int getLayoutId() {
        return R.layout.activity_learnthemticlearning_details;
    }

    private String getStringTime(int cnt) {
        int hour = cnt / 3600;
        int min = cnt % 3600 / 60;
        int second = cnt % 60;
        return String.format(Locale.CHINA, "%02d:%02d:%02d", hour, min, second);
    }


    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.img_playorpause) {
            toggle();
        } else if (id == R.id.img_Courseback) {/*if(stId== 510016 || stId== 510017 || stId== 510018 || stId== 510019) {  //四川专题
                    //HelpUtil.showTiShiDialog(LearnthemticlearningDetailsActivity.this,"该专题课程未学完将不会保存学习记录");
                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                    builder1.setMessage("该专题课程未学完将不会保存学习记录");
                    builder1.setTitle("提示:");
                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.clear();
                            edit.commit();
                            timerTask.cancel();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            finish();
                        }
                    });
                    builder1.create().show();
                    return;
                }*/
            LoginUserBean userInfo2 = UserManger.getUserInfo();
            String userId3 = userInfo2.getData().getUserId();
            SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId3,
                    Context.MODE_PRIVATE);
            int tcsn = sp1.getInt("tcsn", 0);
            int uschSn = sp1.getInt("uschSn", 0);
            String formats2 = sp1.getString("format" + tcsn + uschSn, "");
            int courseLength2 = sp1.getInt("courseLength", 0);
            int sn2 = sp1.getInt("sn", 0);
            String[] splitformat2 = formats2.split(":");
            String formatstr7 = splitformat2[0];
            String formatstr8 = splitformat2[1];
            String formatstr9 = splitformat2[2];
            int iformat7 = Integer.valueOf(formatstr7);//转int
            int iformat8 = Integer.valueOf(formatstr8);//转int
            int iformat9 = Integer.valueOf(formatstr9);//转int
            int formattime2 = iformat7 * 3600 + iformat8 * 60 + iformat9 * 1;
            if (formattime2 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dialog.dismiss();
                    }
                });
            } else {
                if (formattime2 >= courseLength2 * 60) {
                    if (rowscourseList.size() != 0) {
                        for (int i = 0; i < rowscourseList.size(); i++) {
                            if (rowscourseList.get(i).isSelect() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        ;
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                                return;
                            } else {
                                if (rowscourseList.get(i).isLOOP() == false) {
                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                    builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                    builder1.setTitle("提示:");
                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.dismiss();
                                            ;
                                            //设置你的操作事项
                                        }
                                    });
                                    builder1.create().show();
                                    return;
                                }
                            }
                        }
                    }


                    int tphotoMark = sp1.getInt("tphotoMark", 0);
                    if (tphotoMark == 1) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        //有题目调提交接口
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 0) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 2) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 3) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 4) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
                        String imgurl3 = sp1.getString("imgurl3" + tcsn + uschSn, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第二次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstrsub);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numFifthpartstrsub);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 5) {
                        String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                        String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                        String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
                        String imgurl3 = sp1.getString("imgurl3" + tcsn + uschSn, "");
                        String imgurl4 = sp1.getString("imgurl4" + tcsn + uschSn, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog6();
                            return;
                        }
                        String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                        String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                        String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                        String numfourpartstr = sp1.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                        String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstrsub = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstrsub);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numfourpartstrsub);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl4);
                        userTcPhoto4.setSnapTime(numFifthpartstrsub);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1, mac, stId, photoList, 3);
                    }

                } else if (formattime2 < courseLength2 * 60) {
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    int tcsn1 = sp.getInt("tcsn", 0);
                    int uschSn1 = sp.getInt("uschSn", 0);
                    int sn = sp.getInt("sn", 0);
                    int tphotoMark = sp.getInt("tphotoMark", 0);
                    int readLength = (formattime2 % 60 == 0) ? formattime2 / 60 : (formattime2 / 60);//累计学习时间
                    //    int readLength = (formattime2 % 60 != 0) ? formattime2 / 60+1 : (formattime2 / 60);//累计学习时间
                    if (tphotoMark == 1) {
                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    } else if (tphotoMark == 0) {
                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //  String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl1);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    } else if (tphotoMark == 2) {
                        String firsttimestr = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn1, "");//第二次抓拍时间
                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                        //    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numFifthpartstr1);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    } else if (tphotoMark == 3) {
                        String firsttimestr = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn1, "");//第三次抓拍时间

                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl3 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                        //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numFifthpartstr1);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    } else if (tphotoMark == 4) {
                        String firsttimestr = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstrstr1 = sp.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn1, "");//第四次抓拍时间

                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl3 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        String imgurl4 = sp.getString("imgurl3" + tcsn1 + uschSn1, "");
                        String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                        //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numthirdpartstrstr1);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numthirdpartstrstr1sub = numthirdpartstrstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        if (imgurl4.equals("")) {
                            userTcPhoto3.setSnapTime(numFifthpartstr1);
                            userTcPhoto3.setUrl(imgurl4);

                        } else {
                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                            userTcPhoto3.setUrl(imgurl4);
                        }
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    } else if (tphotoMark == 5) {
                        String firsttimestr = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr1 = sp.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numfourpartstr1 = sp.getString("numfourpartstr" + tcsn1, "");//第三次抓拍时间
                        String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn1, "");//第五次抓拍时间

                        String imgurl1 = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl3 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        String imgurl4 = sp.getString("imgurl3" + tcsn1 + uschSn1, "");
                        String imgurl5 = sp.getString("imgurl4" + tcsn1 + uschSn1, "");
                        String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                        //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl1);
                        userTcPhoto.setSnapTime(firsttimesub);
                        photoList.add(userTcPhoto);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        if (imgurl2.equals("")) {
                            userTcPhoto1.setSnapTime(numsecondpartstr1);
                            userTcPhoto1.setUrl(imgurl2);

                        } else {
                            String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                            userTcPhoto1.setUrl(imgurl2);
                        }
                        photoList.add(userTcPhoto1);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        if (imgurl3.equals("")) {
                            userTcPhoto2.setSnapTime(numthirdpartstr1);
                            userTcPhoto2.setUrl(imgurl3);

                        } else {
                            String numthirdpartstrstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                            userTcPhoto2.setUrl(imgurl3);
                        }
                        photoList.add(userTcPhoto2);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        if (imgurl4.equals("")) {
                            userTcPhoto3.setSnapTime(numfourpartstr1);
                            userTcPhoto3.setUrl(imgurl4);

                        } else {
                            String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto3.setSnapTime(numfourpartstr1sub);
                            userTcPhoto3.setUrl(imgurl4);
                        }
                        photoList.add(userTcPhoto3);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        if (imgurl5.equals("")) {
                            userTcPhoto4.setSnapTime(numFifthpartstr1);
                            userTcPhoto4.setUrl(imgurl5);

                        } else {
                            String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                            userTcPhoto4.setUrl(imgurl5);
                        }
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        initsavedata(uschSn1, sn, tcsn1, readLength, photoList);
                    }
                }
//                        }
//                    });
            }
        } else if (id == R.id.tv_course12) {//中途保存
                /*if(stId== 510016 || stId== 510017 || stId== 510018 || stId== 510019) {  //四川专题
                    //HelpUtil.showTiShiDialog(LearnthemticlearningDetailsActivity.this,"该专题课程未学完将不会保存学习记录");
                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                    builder1.setMessage("该专题课程未学完将不会保存学习记录");
                    builder1.setTitle("提示:");
                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.clear();
                            edit.commit();
                            timerTask.cancel();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            finish();
                        }
                    });
                    builder1.create().show();
                    return;
                }*/
            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId1 = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                    Context.MODE_PRIVATE);
            int tcsn1 = sp.getInt("tcsn", 0);
            int sn1 = sp.getInt("sn", 0);
            int uschSn1 = sp.getInt("uschSn", 0);
            int courseLength1 = sp.getInt("courseLength", 0);
            String formats1 = sp.getString("format" + tcsn1 + uschSn1, "");
            String[] splitformat1 = formats1.split(":");
            String formatstr1 = splitformat1[0];
            String formatstr2 = splitformat1[1];
            String formatstr3 = splitformat1[2];
            int iformat4 = Integer.valueOf(formatstr1);//转int
            int iformat5 = Integer.valueOf(formatstr2);//转int
            int iformat6 = Integer.valueOf(formatstr3);//转int
            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
            if (formattime1 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });
                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                    }
                });
            } else {//滿一分鐘保存
                if (formattime1 >= courseLength1 * 60) {
                    if (rowscourseList.size() != 0) {
                        for (int i = 0; i < rowscourseList.size(); i++) {
                            if (rowscourseList.get(i).isSelect() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        ;
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                                return;
                            } else {
                                if (rowscourseList.get(i).isLOOP() == false) {
                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                    builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                    builder1.setTitle("提示:");
                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            dialog.dismiss();
                                            ;
                                            //设置你的操作事项
                                        }
                                    });
                                    builder1.create().show();
                                    return;
                                }
                            }
                        }
                    }
                    int tphotoMark = sp.getInt("tphotoMark", 0);
                    if (tphotoMark == 1) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        //有题目调提交接口
                        if (imgurl.equals("")) {
                            initDialog();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttimesub);
                        userTcPhoto.setUrl(imgurl);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 0) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setSnapTime(firsttime);
                        userTcPhoto.setUrl(imgurl);
                        photoList.add(userTcPhoto);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 2) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn1, "");//第二次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 3) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn1, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 4) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        String imgurl3 = sp.getString("imgurl3" + tcsn1 + uschSn1, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn1, "");//第二次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn1, "");//第三次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstrsub);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numFifthpartstrsub);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    } else if (tphotoMark == 5) {
                        String imgurl = sp.getString("imgurl" + tcsn1 + uschSn1, "");
                        String imgurl1 = sp.getString("imgurl1" + tcsn1 + uschSn1, "");
                        String imgurl2 = sp.getString("imgurl2" + tcsn1 + uschSn1, "");
                        String imgurl3 = sp.getString("imgurl3" + tcsn1 + uschSn1, "");
                        String imgurl4 = sp.getString("imgurl4" + tcsn1 + uschSn1, "");
                        if (imgurl.equals("")) {
                            timerTask.cancel();
                            initDialog();
                            return;
                        }
                        if (imgurl1.equals("")) {
                            timerTask.cancel();
                            initDialog3();
                            return;
                        }
                        if (imgurl2.equals("")) {
                            timerTask.cancel();
                            initDialog4();
                            return;
                        }
                        if (imgurl3.equals("")) {
                            timerTask.cancel();
                            initDialog5();
                            return;
                        }
                        if (imgurl4.equals("")) {
                            timerTask.cancel();
                            initDialog6();
                            return;
                        }
                        String firsttime = sp.getString("firsttime" + tcsn1, "");//第一次抓拍时间
                        String numsecondpartstr = sp.getString("numsecondpartstr" + tcsn1, "");//第二次抓拍时间
                        String numthirdpartstr = sp.getString("numthirdpartstr" + tcsn1, "");//第三次抓拍时间
                        String numfourpartstr = sp.getString("numfourpartstr" + tcsn1, "");//第四次抓拍时间
                        String numFifthpartstr = sp.getString("numFifthpartstr" + tcsn1, "");//第五次抓拍时间
                        String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numfourpartstrsub = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                        List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                        UserTcPhoto userTcPhoto = new UserTcPhoto();
                        userTcPhoto.setUrl(imgurl);
                        userTcPhoto.setSnapTime(firsttimesub);
                        UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                        userTcPhoto1.setUrl(imgurl1);
                        userTcPhoto1.setSnapTime(numsecondpartstrsub);
                        UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                        userTcPhoto2.setUrl(imgurl2);
                        userTcPhoto2.setSnapTime(numthirdpartstrsub);
                        UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                        userTcPhoto3.setUrl(imgurl3);
                        userTcPhoto3.setSnapTime(numfourpartstrsub);
                        UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                        userTcPhoto4.setUrl(imgurl4);
                        userTcPhoto4.setSnapTime(numFifthpartstrsub);
                        photoList.add(userTcPhoto);
                        photoList.add(userTcPhoto1);
                        photoList.add(userTcPhoto2);
                        photoList.add(userTcPhoto3);
                        photoList.add(userTcPhoto4);
                        Gson gson = new Gson();
                        String strphotoList = gson.toJson(photoList);
                        LogUtils.e("strphotoList", strphotoList);
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn1, sn1, tcsn1, courseLength1, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn1, sn1, tcsn1, courseLength1, 1, mac, stId, photoList, 3);
                    }

                } else if (formattime1 < courseLength1 * 60) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                    tv_message.setText("您的学习进度已保存，下次进入将继续本课程的学习。");
                    TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                    btn_sure.setText("确认退出");
                    btn_cancel.setText("继续学习");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view1);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int tcsn = sp.getInt("tcsn", 0);
                            int sn = sp.getInt("sn", 0);
                            int uschSn = sp.getInt("uschSn", 0);
                            String formats1 = sp.getString("format" + tcsn + uschSn, "");
                            String[] splitformat1 = formats1.split(":");
                            String formatstr1 = splitformat1[0];
                            String formatstr2 = splitformat1[1];
                            String formatstr3 = splitformat1[2];
                            int iformat4 = Integer.valueOf(formatstr1);//转int
                            int iformat5 = Integer.valueOf(formatstr2);//转int
                            int iformat6 = Integer.valueOf(formatstr3);//转int
                            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
                            int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                            //  int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1 : (formattime1 / 60);//累计学习时间
                            int tphotoMark = sp.getInt("tphotoMark", 0);
                            if (tphotoMark == 1) {
                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttimesub);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            } else if (tphotoMark == 0) {
                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                //  String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                                //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setSnapTime(firsttime);
                                userTcPhoto.setUrl(imgurl1);
                                photoList.add(userTcPhoto);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            } else if (tphotoMark == 2) {
                                String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                //  String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setUrl(imgurl1);
                                userTcPhoto.setSnapTime(firsttimesub);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numFifthpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            } else if (tphotoMark == 3) {
                                String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间

                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                                String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                //       String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                //      String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setUrl(imgurl1);
                                userTcPhoto.setSnapTime(firsttimesub);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numFifthpartstr1);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            } else if (tphotoMark == 4) {
                                String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String numthirdpartstrstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                                String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间

                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                                String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                                String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setUrl(imgurl1);
                                userTcPhoto.setSnapTime(firsttimesub);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numthirdpartstrstr1);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numthirdpartstrstr1sub = numthirdpartstrstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);
                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                if (imgurl4.equals("")) {
                                    userTcPhoto3.setSnapTime(numFifthpartstr1);
                                    userTcPhoto3.setUrl(imgurl4);

                                } else {
                                    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                                    userTcPhoto3.setUrl(imgurl4);
                                }
                                photoList.add(userTcPhoto3);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            } else if (tphotoMark == 5) {
                                String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                                String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                                String numthirdpartstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                                String numfourpartstr1 = sp.getString("numfourpartstr" + tcsn, "");//第三次抓拍时间
                                String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间

                                String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                                String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                                String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                                String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                                String imgurl5 = sp.getString("imgurl4" + tcsn + uschSn, "");
                                String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                                //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                                UserTcPhoto userTcPhoto = new UserTcPhoto();
                                userTcPhoto.setUrl(imgurl1);
                                userTcPhoto.setSnapTime(firsttimesub);
                                photoList.add(userTcPhoto);
                                UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                                if (imgurl2.equals("")) {
                                    userTcPhoto1.setSnapTime(numsecondpartstr1);
                                    userTcPhoto1.setUrl(imgurl2);

                                } else {
                                    String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                    userTcPhoto1.setUrl(imgurl2);
                                }
                                photoList.add(userTcPhoto1);
                                UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                                if (imgurl3.equals("")) {
                                    userTcPhoto2.setSnapTime(numthirdpartstr1);
                                    userTcPhoto2.setUrl(imgurl3);

                                } else {
                                    String numthirdpartstrstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                                    userTcPhoto2.setUrl(imgurl3);
                                }
                                photoList.add(userTcPhoto2);
                                UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                                if (imgurl4.equals("")) {
                                    userTcPhoto3.setSnapTime(numfourpartstr1);
                                    userTcPhoto3.setUrl(imgurl4);

                                } else {
                                    String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto3.setSnapTime(numfourpartstr1sub);
                                    userTcPhoto3.setUrl(imgurl4);
                                }
                                photoList.add(userTcPhoto3);
                                UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                                if (imgurl5.equals("")) {
                                    userTcPhoto4.setSnapTime(numFifthpartstr1);
                                    userTcPhoto4.setUrl(imgurl5);

                                } else {
                                    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                    userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                                    userTcPhoto4.setUrl(imgurl5);
                                }
                                photoList.add(userTcPhoto4);
                                Gson gson = new Gson();
                                String strphotoList = gson.toJson(photoList);
                                LogUtils.e("strphotoList", strphotoList);
                                initsavedata(uschSn, sn, tcsn, readLength, photoList);
                            }
                            //设置你的操作事项
                        }
                    });

                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {

                            dialog.dismiss();
                        }
                    });
                }
            }
        } else if (id == R.id.tv_course10) {//提交
            if (Utils.isFastClicker()) {
                return;
            }
            LoginUserBean userInfo3 = UserManger.getUserInfo();
            String userId2 = userInfo3.getData().getUserId();
            SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId2,
                    Context.MODE_PRIVATE);
            int tcsn2 = sp2.getInt("tcsn", 0);
            int uschSn2 = sp2.getInt("uschSn", 0);
            String format = sp2.getString("format" + tcsn2 + uschSn2, "");
            int num = sp2.getInt("num" + tcsn2, 0);
            int sn = sp2.getInt("sn", 0);
            int courseLength = sp2.getInt("courseLength", 0);
            String[] splitformat = format.split(":");
            String format1 = splitformat[0];
            String format2 = splitformat[1];
            String format3 = splitformat[2];
            int iformat1 = Integer.valueOf(format1);//转int
            int iformat2 = Integer.valueOf(format2);//转int
            int iformat3 = Integer.valueOf(format3);//转int
            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
            LogUtils.e("测试", "onClick: " + formattime + "  " + num);
            if (formattime < num) {
                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                builder1.setMessage("学习时间不足，不能提交。");
                builder1.setTitle("提示:");
                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        ;
                        //设置你的操作事项
                    }
                });
                builder1.create().show();
            } else {
                if (rowscourseList.size() != 0) {
                    for (int i = 0; i < rowscourseList.size(); i++) {
                        if (rowscourseList.get(i).isSelect() == false) {
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                            builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();
                            return;
                        } else {
                            if (rowscourseList.get(i).isLOOP() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        ;
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                                return;
                            }
                        }
                    }
                }
                int tphotoMark = sp2.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    //有题目调提交接口
                    if (imgurl.equals("")) {
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId5 = userInfo1.getData().getUserId();
                        SharedPreferences sp4 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId5,
                                Context.MODE_PRIVATE);
                        int tcsn3 = sp4.getInt("tcsn", 0);
                        int uschSn3 = sp4.getInt("uschSn", 0);
                        String stringTime = sp4.getString("format" + tcsn3 + uschSn3, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        if (formatTurnSecond > 60) {
                            String firsttime2 = getStringTime(formatTurnSecond);
                            SharedPreferences.Editor edit = sp4.edit();
                            edit.putString("firsttime" + tcsn3, firsttime2);
                            edit.commit();
                            timerTask.cancel();
                            initDialog2();
                        } else {
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                            builder1.setMessage("请等待拍照，才可以提交");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                            builder1.create().show();
                        }
                        return;
                    }
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                } else if (tphotoMark == 0) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttime);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                } else if (tphotoMark == 2) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl1 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    if (imgurl.equals("")) {
                        timerTask.cancel();
                        initDialog();
                        return;
                    }
                    if (imgurl1.equals("")) {
                        timerTask.cancel();
                        initDialog3();
                        return;
                    }
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                } else if (tphotoMark == 3) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl1 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    if (imgurl.equals("")) {
                        timerTask.cancel();
                        initDialog();
                        return;
                    }
                    if (imgurl1.equals("")) {
                        timerTask.cancel();
                        initDialog3();
                        return;
                    }
                    if (imgurl2.equals("")) {
                        timerTask.cancel();
                        initDialog4();
                        return;
                    }
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                } else if (tphotoMark == 4) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl1 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    String imgurl3 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                    if (imgurl.equals("")) {
                        timerTask.cancel();
                        initDialog();
                        return;
                    }
                    if (imgurl1.equals("")) {
                        timerTask.cancel();
                        initDialog3();
                        return;
                    }
                    if (imgurl2.equals("")) {
                        timerTask.cancel();
                        initDialog4();
                        return;
                    }
                    if (imgurl3.equals("")) {
                        timerTask.cancel();
                        initDialog5();
                        return;
                    }
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn2, "");//第二次抓拍时间
                    String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstrsub);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numFifthpartstrsub);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                } else if (tphotoMark == 5) {
                    String imgurl = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl1 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    String imgurl3 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                    String imgurl4 = sp2.getString("imgurl4" + tcsn2 + uschSn2, "");
                    if (imgurl.equals("")) {
                        timerTask.cancel();
                        initDialog();
                        return;
                    }
                    if (imgurl1.equals("")) {
                        timerTask.cancel();
                        initDialog3();
                        return;
                    }
                    if (imgurl2.equals("")) {
                        timerTask.cancel();
                        initDialog4();
                        return;
                    }
                    if (imgurl3.equals("")) {
                        timerTask.cancel();
                        initDialog5();
                        return;
                    }
                    if (imgurl4.equals("")) {
                        timerTask.cancel();
                        initDialog6();
                        return;
                    }
                    String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numthirdpartstr = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                    String numfourpartstr = sp2.getString("numfourpartstr" + tcsn2, "");//第四次抓拍时间
                    String numFifthpartstr = sp2.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numfourpartstrsub = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstrsub);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numfourpartstrsub);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    userTcPhoto4.setUrl(imgurl4);
                    userTcPhoto4.setSnapTime(numFifthpartstrsub);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn2, sn, tcsn2, courseLength, 1, mac, stId, photoList, 3);
                }
//                    else {//没有题目调提交接口
//                        int tphotoMark = sp2.getInt("tphotoMark", 0);
//                        if(tphotoMark==1) {
//                            if (imgurl.equals("")) {
//
//                                LoginUserBean userInfo1 = UserManger.getUserInfo();
//                                String userId5 = userInfo1.getData().getUserId();
//                                SharedPreferences sp4 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId5,
//                                        Context.MODE_PRIVATE);
//                                int tcsn3 = sp4.getInt("tcsn", 0);
//                                int uschSn3 = sp4.getInt("uschSn", 0);
//                                String stringTime = sp4.getString("format" + tcsn3 + uschSn3, "");
//                                int index1 = stringTime.indexOf(":");
//                                int index2 = stringTime.indexOf(":", index1 + 1);
//                                int hh = Integer.parseInt(stringTime.substring(0, index1));
//                                int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
//                                int ss = Integer.parseInt(stringTime.substring(index2 + 1));
//                                int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
//                                if (formatTurnSecond > 60) {
//                                    String firsttime2 = getStringTime(formatTurnSecond);
//                                    SharedPreferences.Editor edit = sp4.edit();
//                                    edit.putString("firsttime" + tcsn3, firsttime2);
//                                    edit.commit();
//                                    timerTask.cancel();
//                                    initDialog2();
//                                } else {
//                                    TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
//                                    builder1.setMessage("请等待拍照，才可以提交");
//                                    builder1.setTitle("提示:");
//                                    builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                                        public void onClick(DialogInterface dialog, int which) {
//                                            dialog.dismiss();
//                                            //设置你的操作事项
//                                        }
//                                    });
//                                    builder1.create().show();
//                                }
//                                return;
//                            }
//                            String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
//                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                            UserTcPhoto userTcPhoto = new UserTcPhoto();
//                            userTcPhoto.setUrl(imgurl);
//                            userTcPhoto.setSnapTime(firsttimesub);
//                            photoList.add(userTcPhoto);
//                            Gson gson = new Gson();
//                            String strphotoList = gson.toJson(photoList);
//                            LogUtils.e("strphotoList", strphotoList);
//                            //     showLoadingDialog("提交中");
//                            mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                            mProgressDialog.setMessage("提交中...");
//                            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                            mProgressDialog.setCancelable(false);
//                            mProgressDialog.show();
//                            new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1, photoList, this, 3);
//                        }else if(tphotoMark==0)
//                        {
//                            String firsttime = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
//                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
//                            //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
//                            UserTcPhoto userTcPhoto = new UserTcPhoto();
//                            userTcPhoto.setSnapTime(firsttime);
//                            userTcPhoto.setUrl(imgurl);
//                            photoList.add(userTcPhoto);
//                            Gson gson = new Gson();
//                            String strphotoList = gson.toJson(photoList);
//                            LogUtils.e("strphotoList", strphotoList);
//                            mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
//                            mProgressDialog.setMessage("提交中...");
//                            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
//                            mProgressDialog.setCancelable(false);
//                            mProgressDialog.show();
//                            new Login().getSureSpeciedcourse(uschSn2, sn, tcsn2, courseLength, 1, photoList, this, 3);
//
//                        }
//
//                   }
            }
        } else if (id == R.id.img_course1) {
            if (!isloob) {
                img_course.setText("展开拍照");
                re_course1.setVisibility(View.GONE);
                img_course2.setImageResource(R.mipmap.down3);
                // le_course1.setVisibility(View.GONE);
                isloob = true;
            } else {
                img_course.setText("收起拍照");
                re_course1.setVisibility(View.VISIBLE);
                img_course2.setImageResource(R.mipmap.top3);
                //  le_course1.setVisibility(View.VISIBLE);
                isloob = false;
            }
        }
    }

    private String getNumTime(int cnt) {
        int hour = cnt / 3600;
        int min = cnt % 3600 / 60;
        int second = cnt % 60;
        if (hour == 0) {

            return String.format(Locale.CHINA, "%02d分%02d秒", min, second);
        } else {

            return String.format(Locale.CHINA, "%02d小时%02d分%02d秒", hour, min, second);
        }
    }

    //离开保存
    private void initsavedata(int uschSn, int sn, int tcsn, int readLength, List<UserTcPhoto> photoList) {
        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
        mProgressDialog.setMessage("离开保存...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        //new Login().getSureSpeciedcourse(uschSn, sn, tcsn, readLength, 0,mac,stId, photoList, this, 4);
        userStCourseSave(uschSn, sn, tcsn, readLength, 0,mac,stId, photoList, 4);
    }

    //提交
    private void initsuredata(int uschSn, int sn, int tcsn, int courseLength, List<UserTcPhoto> photoList) {
        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
        mProgressDialog.setMessage("提交中...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        //new Login().getSureSpeciedcourse(uschSn, sn, tcsn, courseLength, 1,mac,stId, photoList, this, 3);
        userStCourseSave(uschSn, sn, tcsn, courseLength, 1,mac,stId, photoList, 3);
    }

    //小窗口离开保存
    private void initsavedata1(int uschSn, int sn, int tcsn, int readLength, List<UserTcPhoto> photoList) {
        //new Login().getSureSpeciedcourse(uschSn, sn, tcsn, readLength, 0,mac,stId, photoList, this, 5);
        userStCourseSave(uschSn, sn, tcsn, readLength, 0,mac,stId, photoList,  5);
    }

    @Override
    public void initData() {

        web = (WebView) findViewById(R.id.wb_course);
        le_parement = (LinearLayout) findViewById(R.id.le_couse);
        img_Courseback = (ImageView) findViewById(R.id.img_Courseback);
        img_course2 = (ImageView) findViewById(R.id.img_course2);
        lv_coursedetail = (RecyclerView) findViewById(R.id.lv_coursedetail);
        jcVideoPlayerStandard = (MyJZVideoPlayerStandard) findViewById(R.id.videoplayer);
        tv_courseName = (TextView) findViewById(R.id.tv_course);
        tv_courseLength = (TextView) findViewById(R.id.tv_course2);
        tv_cumulativeLength = (TextView)findViewById(R.id.tv_course3);
        show_camera_iv = (ImageView)findViewById(R.id.id_show_camera_iv);
        show_camera_iv1 = (ImageView)findViewById(R.id.id_show_camera_iv1);
        show_camera_iv2 = (ImageView)findViewById(R.id.id_show_camera_iv2);
        show_camera_iv3 = (ImageView)findViewById(R.id.id_show_camera_iv3);
        show_camera_iv4 = (ImageView)findViewById(R.id.id_show_camera_iv4);
        tv_sure = (TextView)findViewById(R.id.tv_course10);
        tv_save = (TextView)findViewById(R.id.tv_course12);
        re_course = (RelativeLayout)findViewById(R.id.re_course);
        re_course1 = (LinearLayout)findViewById(R.id.totalle_course);
        le_course1 = (LinearLayout)findViewById(R.id.le_course1);
        img_course = (TextView) findViewById(R.id.img_course1);
        tv_course11 = (TextView)findViewById(R.id.tv_course11);
        re_course2 = (RelativeLayout)findViewById(R.id.re_course2);
        playOrPauseFab = (ImageView)findViewById(R.id.img_playorpause);
        tv_playorpause = (TextView)findViewById(R.id.tv_playorpause);
        progress_tv = (TextView)findViewById(R.id.progress_tv);
        total_tv = (TextView)findViewById(R.id.total_tv);
        scroll_view = (ScrollView) findViewById(R.id.scrollView);
        mSuperFileView = (SuperFileView2) findViewById(R.id.mSuperFileView);

        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        animation = AnimationUtils.loadAnimation(LearnthemticlearningDetailsActivity.this, R.anim.change_color);
        web.setHorizontalScrollBarEnabled(false);//水平不显示
        web.setVerticalScrollBarEnabled(false); //垂直不显示
        web.setWebViewClient(new WebViewClient() {
            /*
            此处能拦截超链接的url,即拦截href请求的内容。
            */
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return true;
            }
        });
        //注册EventBus
        EventBus.getDefault().register(this);
        musicHandler = new MusicHandler();
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorEventListener = new Jzvd.JZAutoFullscreenListener();
        Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);

        timer1 = new Timer();

        Bundle bundle = getIntent().getExtras();
        //通过name关键字取出用户名

        int tcsn = bundle.getInt("tcsn");
        int uschSn = bundle.getInt("uschSn");
        int sn = bundle.getInt("sn");
        int readLength = bundle.getInt("readLength");
        int minPer = bundle.getInt("minPer");
        int tphotoMark = bundle.getInt("tphotoMark");
        stId = bundle.getInt("stId");
        mac=HelpUtil.getNewMac();
        int apromptMark = bundle.getInt("apromptMark");
        List<LearnthematiclearningBean.RowsBean> listCourse = (List<LearnthematiclearningBean.RowsBean>) bundle.getSerializable("CourseDetailList");


        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt("tcsn", tcsn);
        edit.putInt("uschSn", uschSn);
        edit.putInt("readLength", readLength);
        edit.putInt("sn", sn);
        edit.putInt("stId", stId);
        edit.putInt("minPer", minPer);
        edit.putInt("tphotoMark", tphotoMark);
        edit.putInt("apromptMark", apromptMark);
        if (readLength > 0) {
            String readLengthstr = getStringTime(readLength * 60);
            edit.putString("format" + tcsn + uschSn, readLengthstr);
            int firsttime2 = (int) (readLength * 60 + 20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime2);
            edit.commit();
        } else {
            edit.putString("format" + tcsn + uschSn, "");
            int firsttime2 = (int) (80 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime2" + tcsn, firsttime2);
            int firsttime = (int) (20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime);
            edit.commit();
        }

        Gson gson = new Gson();
        String courseStr = gson.toJson(listCourse); //将List转换成Json
        edit.putString("listCourse", courseStr); //存入json串
        edit.commit();

//        int firsttime = sp.getInt("intfirsttime" + tcsn, 0);
//        if (firsttime == 0) {
//            int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//            edit.putInt("intfirsttime" + tcsn, firsttime1);
//            edit.commit();
//        } else {
//            int firsttime1 = firsttime;
//            edit.putInt("intfirsttime" + tcsn, firsttime1);
//            edit.commit();
//        }

        if (tphotoMark == 1) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(0);
                }
            });
            thread.start();
        } else if (tphotoMark == 0) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(2);
                }
            });
            thread.start();


        } else if (tphotoMark == 2) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(3);
                }
            });
            thread.start();


        } else if (tphotoMark == 3) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(4);
                }
            });
            thread.start();


        } else if (tphotoMark == 4) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(5);
                }
            });
            thread.start();


        } else if (tphotoMark == 5) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(6);
                }
            });
            thread.start();


        }
//        Thread thread1 = new Thread(new Runnable() {
//            @Override
//            public void run() {
//                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
//                mHandler.sendEmptyMessage(1);
//            }
//        });
//        thread1.start();

        initSeekba();//语音播放ui
        //专题培训，学习课程时，首次进入时，立即提交一次
        if (sn == 0) {
            //刚进去时提交一次
            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
            UserTcPhoto userTcPhoto = new UserTcPhoto();
            userTcPhoto.setUrl("");
            userTcPhoto.setSnapTime("");
            photoList.add(userTcPhoto);
            if(stId== 510016 || stId== 510017 || stId== 510018 || stId== 510019){
                return;
            }
            initsavedata1(uschSn, 0, tcsn, 0, photoList);
        }

    }

    private void initSeekba() {

        musicSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                int musicDuration = mediaPlayer.getDuration();
                if (musicDuration == -1) return;

                if (musicDuration < 0) {
                    progress_tv.setText(MusicUtils.getTime(0));
                    total_tv.setText(MusicUtils.getTime(0));
                } else {
                    progress_tv.setText(MusicUtils.getTime(progress));
                    total_tv.setText(MusicUtils.getTime(musicDuration));
                }
                //  LogUtils.e("musicSeekBar",musicDuration+"");

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                int musicDuration = mediaPlayer.getDuration();
                if (musicDuration == -1) return;
                int progress = seekBar.getProgress();
                mediaPlayer.seekTo(progress);
                mediaPlayer.start();
                progress_tv.setText(MusicUtils.getTime(progress));
                total_tv.setText(MusicUtils.getTime(musicDuration));
            }
        });


        initMusicPlayer();
    }

    public void initMusicPlayer() {
        musicPrepared();
        mediaPlayer.setOnCompletionListener(this);
        mediaPlayer.setOnErrorListener(this);

    }

    public void toggle() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        } else if (tv_playorpause.getText().toString().trim().equals("暂停")) {
            start();
        }
    }

    public void start() {
        //     musicPrepared();
        mediaPlayer.start();
        musicHandler.sendEmptyMessage(0);
        playOrPauseFab.setImageResource(R.mipmap.play);
        tv_playorpause.setText("播放");
        //  isPlaying = true;

    }

    public void pause() {
        mediaPlayer.pause();
        musicHandler.removeMessages(0);
        playOrPauseFab.setImageResource(R.mipmap.stop);
        tv_playorpause.setText("暂停");
        //   isPlaying = false;
        //   fmm.stop();
    }

    private void updateProgress() {
        int musicDuration = mediaPlayer.getDuration();
        LogUtils.e("musicDuration", musicDuration + "");
        if (musicDuration == -1) return;
        int musicProgress = mediaPlayer.getCurrentPosition();
        musicSeekBar.setProgress(musicProgress);
        musicSeekBar.setMax(musicDuration);
        //     fmm.setProgress(musicProgress * 100 / musicDuration);
    }

    private void musicPrepared() {
        try {
            //   AssetFileDescriptor afd = getAssets().openFd("99nights.mp3");
            if (mediaPlayer != null) {
                mediaPlayer.reset();
                mediaPlayer = null;
            }
            mediaPlayer = new MediaPlayer();
            mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            int tcsn = sp.getInt("tcsn", 0);
            int uschSn = sp.getInt("uschSn", 0);
            String accessAudioUrl = sp.getString("accessAudioUrl" + tcsn + uschSn, "");
            if (accessAudioUrl.equals("")) {
                // showToast("语音文件是空");
                return;
            }
            Uri uri = Uri.parse(accessAudioUrl);
            mediaPlayer.setDataSource(LearnthemticlearningDetailsActivity.this, uri);
            mediaPlayer.prepareAsync();
            mediaPlayer.setOnPreparedListener(this);

            musicHandler.sendEmptyMessage(0);
            playOrPauseFab.setImageResource(R.mipmap.play);
            tv_playorpause.setText("播放");
//            int duration = mediaPlayer.getDuration();
//            total_tv.setText(MusicUtils.getTime(duration));//刚开始获取时长
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onCompletion(MediaPlayer mp) {
        complete(mp);
    }

    public void complete(MediaPlayer mp) {
        //   isPlaying = false;
        mp.stop();
        musicHandler.removeMessages(0);
        playOrPauseFab.setImageResource(R.mipmap.stop);
        tv_playorpause.setText("暂停");
//        fmm.stop();
//        fmm.setProgress(100);
        musicPrepared();
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.start();
    }

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        LogUtils.e("MMP", "Media player error: what=" + what + ", extra=" + extra);
        return false;
    }

    public class MusicHandler extends Handler {

        @Override
        public void dispatchMessage(Message msg) {
            super.dispatchMessage(msg);
            updateProgress();
            sendEmptyMessageDelayed(0, 1000);
        }
    }

    public void initDataSecond() {
        musicHandler = new MusicHandler();
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorEventListener = new Jzvd.JZAutoFullscreenListener();
        Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);

        timer1 = new Timer();

        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int sn = sp.getInt("sn", 0);
        int uschSn = sp.getInt("uschSn", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
        int readLength = sp.getInt("readLength", 0);
        //  String format = sp.getString("format" + tcsn+uschSn, "");
        SharedPreferences.Editor edit = sp.edit();
        if (readLength > 0) {
            int firsttime2 = (int) (readLength * 60 + 20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime2);
            edit.commit();
        } else {
            int firsttime2 = (int) (80 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime2" + tcsn, firsttime2);
            int firsttime = (int) (20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
            edit.putInt("intfirsttime" + tcsn, firsttime);
            edit.commit();
        }
        if (tphotoMark == 1) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(0);
                }
            });
            thread.start();
        } else if (tphotoMark == 0) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(2);
                }
            });
            thread.start();
        } else if (tphotoMark == 2) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(3);
                }
            });
            thread.start();


        } else if (tphotoMark == 3) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(4);
                }
            });
            thread.start();


        } else if (tphotoMark == 4) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(5);
                }
            });
            thread.start();


        } else if (tphotoMark == 5) {

            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                    mHandler.sendEmptyMessage(6);
                }
            });
            thread.start();


        }

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                mHandler.sendEmptyMessage(1);
            }
        });
        thread1.start();
        //专题培训，学习课程时，首次进入时，立即提交一次
        if (sn == 0) {
            //刚进去时提交一次
            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
            UserTcPhoto userTcPhoto = new UserTcPhoto();
            userTcPhoto.setUrl("");
            userTcPhoto.setSnapTime("");
            photoList.add(userTcPhoto);
            initsavedata1(uschSn, 0, tcsn, 0, photoList);
        }
        initSeekba();//语音播放ui

    }

    //查询拍照照片
    private void initcoursephoto() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int uscSn = sp.getInt("sn", 0);
        if (uscSn == 0) {
            le_course1.setVisibility(View.GONE);
            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
            show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
            return;
        }
        showLoadingDialog("");
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/userStcPhoto/findByUsCourseSn/" + uscSn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                dismissLoadingDialog();
                SpecifiedPhotoBean specifiedPhotoBean = JSON.parseObject(result, SpecifiedPhotoBean.class);
                List<SpecifiedPhotoBean.RowsBean> rows = specifiedPhotoBean.getRows();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    }
                    String url = specifiedPhotoBean.getRows().get(0).getUrl();
                    LoginUserBean userInfo1 = UserManger.getUserInfo();
                    String userId1 = userInfo1.getData().getUserId();
                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                            Context.MODE_PRIVATE);
                    int tcsn = sp1.getInt("tcsn", 0);
                    int uschSn = sp1.getInt("uschSn", 0);
                    String format = sp1.getString("format" + tcsn + uschSn, "");
                    if (format.equals("")) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                    } else {
                        String[] splitformat = format.split(":");
                        String format1 = splitformat[0];
                        String format2 = splitformat[1];
                        String format3 = splitformat[2];
                        int iformat1 = Integer.valueOf(format1);//转int
                        int iformat2 = Integer.valueOf(format2);//转int
                        int iformat3 = Integer.valueOf(format3);//转int
                        int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                        if (formattime >= 60) {
                            show_camera_iv.setWillNotDraw(false);//添加图片内容
                            SharedPreferences.Editor edit = sp1.edit();
                            edit.putString("imgurl" + tcsn + uschSn, url);
                            edit.commit();
                            if (url.contains("aliyuncs.com")) {
                                Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                            } else {

                                Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                            }
                        } else {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                        }
                    }

                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }

                    } else if (rows.size() >= 2) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (rows.size() == 0) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }

                    } else if (rows.size() == 2) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }

                    } else if (rows.size() >= 3) {
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    }
                } else if (tphotoMark == 4) {
                    if (rows.size() == 0) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }

                    } else if (rows.size() == 2) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }

                    } else if (rows.size() == 3) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    } else if (rows.size() >= 4) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + uschSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    }
                } else if (tphotoMark == 5) {
                    if (rows.size() == 0) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        return;
                    } else if (rows.size() == 1) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                        }

                    } else if (rows.size() == 2) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }

                    } else if (rows.size() == 3) {
                        le_course1.setVisibility(View.GONE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        int numsecondpart = sp1.getInt("numsecondpart" + tcsn, 0);
                        int numFifthpart = sp1.getInt("numFifthpart" + tcsn, 0);
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    } else if (rows.size() == 4) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + uschSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    } else if (rows.size() >= 5) {
                        le_course1.setVisibility(View.VISIBLE);
                        String url = specifiedPhotoBean.getRows().get(0).getUrl();
                        String url1 = specifiedPhotoBean.getRows().get(1).getUrl();
                        String url2 = specifiedPhotoBean.getRows().get(2).getUrl();
                        String url3 = specifiedPhotoBean.getRows().get(3).getUrl();
                        String url4 = specifiedPhotoBean.getRows().get(4).getUrl();
                        LoginUserBean userInfo1 = UserManger.getUserInfo();
                        String userId1 = userInfo1.getData().getUserId();
                        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp1.getInt("tcsn", 0);
                        int uschSn = sp1.getInt("uschSn", 0);
                        String format = sp1.getString("format" + tcsn + uschSn, "");
                        if (format.equals("")) {
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                        } else {
                            String[] splitformat = format.split(":");
                            String format1 = splitformat[0];
                            String format2 = splitformat[1];
                            String format3 = splitformat[2];
                            int iformat1 = Integer.valueOf(format1);//转int
                            int iformat2 = Integer.valueOf(format2);//转int
                            int iformat3 = Integer.valueOf(format3);//转int
                            int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
                            if (formattime >= 60) {
                                show_camera_iv.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl" + tcsn + uschSn, url);
                                edit.commit();
                                if (url.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url)).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data).into(show_camera_iv);
                                }
                            } else {
                                show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容

                            }
                            if (formattime >= 60) {
                                show_camera_iv1.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl1" + tcsn + uschSn, url1);
                                edit.commit();
                                if (url1.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url1)).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url1))).placeholder(R.mipmap.no_data).into(show_camera_iv1);
                                }
                            } else {
                                show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv2.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl2" + tcsn + uschSn, url2);
                                edit.commit();
                                if (url2.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url2)).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url2))).placeholder(R.mipmap.no_data).into(show_camera_iv2);
                                }
                            } else {
                                show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv3.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl3" + tcsn + uschSn, url3);
                                edit.commit();
                                if (url3.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url3)).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url3))).placeholder(R.mipmap.no_data).into(show_camera_iv3);
                                }
                            } else {
                                show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                            if (formattime >= 60) {
                                show_camera_iv4.setWillNotDraw(false);//添加图片内容
                                SharedPreferences.Editor edit = sp1.edit();
                                edit.putString("imgurl4" + tcsn + uschSn, url4);
                                edit.commit();
                                if (url4.contains("aliyuncs.com")) {
                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(url4)).placeholder(R.mipmap.no_data).into(show_camera_iv4);
                                } else {

                                    Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url4))).placeholder(R.mipmap.no_data).into(show_camera_iv4);
                                }
                            } else {
                                show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
                            }
                        }
                    }
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                // showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    @Override
    public void onFailure(Call call, int what) {
        super.onFailure(call, what);
        if (what == 3) {
            mProgressDialog.dismiss();
            Toast.makeText(LearnthemticlearningDetailsActivity.this, "提交失败，重新提交", Toast.LENGTH_LONG).show();
        } else if (what == 4) {
            mProgressDialog.dismiss();
            Toast.makeText(LearnthemticlearningDetailsActivity.this, "保存失败，重新保存", Toast.LENGTH_LONG).show();
        }

    }

    @Override
    public void onSuccess(String result, Call call, Response response, int what) {
        if (what == 3) {
            mProgressDialog.dismiss();
            SignBean signBean = JSON.parseObject(result, SignBean.class);
            SignBean.DataBean data = signBean.getData();
            if (data.getFinishMark() == 0)//未完成
            {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                String courseStr = sp.getString("listCourse", "");  //取出key为"KEY_PEOPLE_DATA"的值，如果值为空，则将第二个参数作为默认值赋值
                Gson gson = new Gson();

                //将json字符串转换成 people对象
                List<LearnthematiclearningBean.RowsBean> CourseDetailList = gson.fromJson(courseStr, new TypeToken<List<LearnthematiclearningBean.RowsBean>>() {}.getType());
                if (CourseDetailList.size() > 0) {
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;

                    if( !forbidHourJudge()) {  //禁学时间段
                        TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
                        builder1.setMessage("安全第一，现在是休息时间，明天再来学吧！");
                        builder1.setTitle("提示:");
                        builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();

                                SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                        Context.MODE_PRIVATE);
                                SharedPreferences.Editor edit = sp1.edit();
                                int tcsn = sp1.getInt("tcsn", 0);
                                int uschSn = sp1.getInt("uschSn", 0);
                                edit.remove("imgurl" + tcsn + uschSn);
                                edit.remove("imgurl1" + tcsn + uschSn);
                                edit.remove("imgurl2" + tcsn + uschSn);
                                edit.remove("imgurl3" + tcsn + uschSn);
                                edit.remove("imgurl4" + tcsn + uschSn);
                                edit.remove("format" + tcsn + uschSn);
                                edit.remove("firsttime" + tcsn);
                                edit.remove("num" + tcsn);
                                edit.remove("intfirsttime" + tcsn);
                                edit.remove("accessAudioUrl" + tcsn + uschSn);
                                edit.remove("tag" + tcsn);
                                edit.commit();
                                finish();
                            }
                        });
                        builder1.create().show();
                        return;
                    }

                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("您好!当前课程学完了,是否想学习下一课程");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_sure.setText("学习");
                    btn_cancel.setText("离开");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            //设置你的操作事项
                            scroll_view.fullScroll(ScrollView.FOCUS_UP);//滑到顶部
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences spp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId, Context.MODE_PRIVATE);
                            int tcsn = spp.getInt("tcsn", 0);
                            int uschSn = spp.getInt("uschSn", 0);
                            SharedPreferences.Editor editor = spp.edit();
                            editor.remove("imgurl" + tcsn + uschSn);
                            editor.remove("accessAudioUrl" + tcsn + uschSn);
                            editor.commit();
                            int tcSn1 = CourseDetailList.get(0).getTcSn();
                            int sn = CourseDetailList.get(0).getSn();
                            int readLength = CourseDetailList.get(0).getReadLength();
                            SharedPreferences.Editor edit = spp.edit();
                            edit.putInt("readLength", readLength);
                            edit.putInt("sn", sn);
                            edit.putInt("tcsn", tcSn1);
                            if (readLength > 0) {
                                String readLengthstr = getStringTime(readLength * 60);
                                edit.putString("format" + tcSn1 + uschSn, readLengthstr);
                            } else {
                                edit.putString("format" + tcSn1 + uschSn, "");
                            }
                            ArrayList<LearnthematiclearningBean.RowsBean> CourseList = new ArrayList<>();
                            CourseList.clear();
                            for (int i = 0; i < CourseDetailList.size(); i++) {
                                if (CourseDetailList.get(i).getTcSn() != tcSn1) {
                                    CourseList.add(CourseDetailList.get(i));
                                }

                            }
                            Gson gson = new Gson();
                            String courseStr = gson.toJson(CourseList); //将List转换成Json
                            edit.putString("listCourse", courseStr); //存入json串
                            edit.commit();
                            Jzvd.resetAllVideos();//释放视频资源
                            show_camera_iv.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv1.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv2.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv3.setImageResource(R.mipmap.tongming);//清除图片内容
                            show_camera_iv4.setImageResource(R.mipmap.tongming);//清除图片内容
                            img_course.setText("展开拍照");
                            img_course2.setImageResource(R.mipmap.down3);
                            re_course1.setVisibility(View.GONE);
                            mediaPlayer.stop();
                            musicHandler.removeMessages(0);
                            playOrPauseFab.setImageResource(R.mipmap.stop);
                            tv_playorpause.setText("暂停");
                            musicSeekBar.setProgress(0);
                            progress_tv.setText(MusicUtils.getTime(0));
                            total_tv.setText(MusicUtils.getTime(0));
                            initcourseData();  //根据课程序列号查询课程详情
                            initcoursesubject(); //根据课程序列号查询测验题
                            initDataSecond();//初始化
                            initcoursephoto();//查询拍照照片
                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            int tcsn = sp1.getInt("tcsn", 0);
                            int uschSn = sp1.getInt("uschSn", 0);
                            edit.remove("imgurl" + tcsn + uschSn);
                            edit.remove("imgurl1" + tcsn + uschSn);
                            edit.remove("imgurl2" + tcsn + uschSn);
                            edit.remove("imgurl3" + tcsn + uschSn);
                            edit.remove("imgurl4" + tcsn + uschSn);
                            edit.remove("format" + tcsn + uschSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + uschSn);
                            edit.remove("tag" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });

                } else if (CourseDetailList.size() == 0) {
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;
                    LoginUserBean userInfo1 = UserManger.getUserInfo();
                    String userId1 = userInfo1.getData().getUserId();
                    SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp1.edit();
                    int tcsn = sp1.getInt("tcsn", 0);
                    int uschSn = sp1.getInt("uschSn", 0);
                    edit.remove("imgurl" + tcsn + uschSn);
                    edit.remove("imgurl1" + tcsn + uschSn);
                    edit.remove("imgurl2" + tcsn + uschSn);
                    edit.remove("imgurl3" + tcsn + uschSn);
                    edit.remove("imgurl4" + tcsn + uschSn);
                    edit.remove("format" + tcsn + uschSn);
                    edit.remove("firsttime" + tcsn);
                    edit.remove("num" + tcsn);
                    edit.remove("intfirsttime" + tcsn);
                    edit.remove("accessAudioUrl" + tcsn + uschSn);
                    edit.remove("tag" + tcsn);
                    edit.commit();
                    finish();
                    showToast("该课程提交成功");
                }
            } else if (data.getFinishMark() == 1)//已完成未签名
            {
                timerTask.cancel();
                timer1.cancel();
                timerTask = null;
                timer1 = null;
                LoginUserBean userInfo1 = UserManger.getUserInfo();
                String userId1 = userInfo1.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp.edit();
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                Bundle bundle = new Bundle();
                bundle.putInt("sn", uschSn);
                bundle.putString("signPicUrl", "");
                startActivity(SignSpeciedlearningActivity.class, bundle);
                finish();
                showToast("该课程提交成功");
                edit.remove("imgurl" + tcsn + uschSn);
                edit.remove("imgurl1" + tcsn + uschSn);
                edit.remove("imgurl2" + tcsn + uschSn);
                edit.remove("imgurl3" + tcsn + uschSn);
                edit.remove("imgurl4" + tcsn + uschSn);
                edit.remove("format" + tcsn + uschSn);
                edit.remove("firsttime" + tcsn);
                edit.remove("num" + tcsn);
                edit.remove("intfirsttime" + tcsn);
                edit.remove("accessAudioUrl" + tcsn + uschSn);
                edit.remove("tag" + tcsn);
                edit.commit();
            } else if (data.getFinishMark() == 2) {

                timerTask.cancel();
                timer1.cancel();
                timerTask = null;
                timer1 = null;
                LoginUserBean userInfo1 = UserManger.getUserInfo();
                String userId1 = userInfo1.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp.edit();
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                edit.remove("imgurl" + tcsn + uschSn);
                edit.remove("imgurl1" + tcsn + uschSn);
                edit.remove("imgurl2" + tcsn + uschSn);
                edit.remove("imgurl3" + tcsn + uschSn);
                edit.remove("imgurl4" + tcsn + uschSn);
                edit.remove("format" + tcsn + uschSn);
                edit.remove("firsttime" + tcsn);
                edit.remove("num" + tcsn);
                edit.remove("intfirsttime" + tcsn);
                edit.remove("accessAudioUrl" + tcsn + uschSn);
                edit.remove("tag" + tcsn);
                edit.commit();
                finish();
                showToast("该课程提交成功");
            }
        } else if (what == 4) {
            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            SharedPreferences.Editor edit = sp1.edit();
            edit.clear();
            edit.commit();
            mProgressDialog.dismiss();
            timerTask.cancel();
            timer1.cancel();
            timerTask = null;
            timer1 = null;
            finish();
        } else if (what == 5) {
            //  showToast("刚进入提交成功");
        } else if (what == 6)//头像
        {
            MineUseBean mineUseBean = JSON.parseObject(result, MineUseBean.class);
            MineUseBean.DataBean data = mineUseBean.getData();
            String photoUrl = data.getPhotoUrl();
            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            SharedPreferences.Editor edit = sp.edit();
            edit.putString("photoUrl", photoUrl);
            edit.commit();

        }


        super.onSuccess(result, call, response, what);
    }

    @Override
    public void onError(String result, Call call, Response response, int what) {
        if (what == 3) {
            mProgressDialog.dismiss();
            CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
            //     int code = checkBean.getCode();
            String msg = checkBean.getMsg();
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
            builder1.setMessage(msg);
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    //设置你的操作事项
                }
            });
            builder1.create().show();
        } else if (what == 4) {
            mProgressDialog.dismiss();
            CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
            //     int code = checkBean.getCode();
            String msg = checkBean.getMsg();
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
            builder1.setMessage(msg);
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    ;
                    //设置你的操作事项
                }
            });
            builder1.create().show();
        }

        super.onError(result, call, response, what);
    }

    @Override
    public void requestData() {
        initcourseData();//根据课程序列号查询课程详情
        initcoursephoto();//查询拍照照片
        initcoursesubject(); //根据课程序列号查询测验题
        usedata();//刷新头像

    }

    private void usedata() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        LoginUserBean.DataBean data = userInfo.getData();
        String userId = data.getUserId();
        new Login().getUser(userId, this, 6);
    }

    //根据课程序列号查询测验题
    private void initcoursesubject() {
        LoginUserBean userInfo1 = UserManger.getUserInfo();
        String userId1 = userInfo1.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/question/" + tcsn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                CourseDetailSubjectBean courseDetailSubjectBean = JSON.parseObject(result, CourseDetailSubjectBean.class);
                List<CourseDetailSubjectBean.RowsBean> rows = courseDetailSubjectBean.getRows();
                if (rows.size() == 0) {
                    lv_coursedetail.setAdapter(null);
                    tv_course11.setVisibility(View.GONE);
                    return;
                }
                rowscourseList.clear();
                rowscourseList.addAll(rows);
                tv_course11.setVisibility(View.VISIBLE);
                RecyclerView.LayoutManager layoutManager=new LinearLayoutManager(LearnthemticlearningDetailsActivity.this);
                lv_coursedetail.setLayoutManager(layoutManager);
                courseDetailSubjectApt = new CourseDetailRvSubjectApt(LearnthemticlearningDetailsActivity.this, rowscourseList);
                //courseDetailSubjectApt = new SpecifiedCourseDetailSubjectApt(LearnthemticlearningDetailsActivity.this, rowscourseList, R.layout.course_detail_item);
                lv_coursedetail.setAdapter(courseDetailSubjectApt);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    //根据课程序列号查询课程详情
    private void initcourseData() {
        LoginUserBean userInfo1 = UserManger.getUserInfo();
        String userId1 = userInfo1.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "course/course/" + tcsn);
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                CourseDetailBean courseDetailBean = JSON.parseObject(result, CourseDetailBean.class);
                CourseDetailBean.DataBean coursedata = courseDetailBean.getData();
                String courseName = coursedata.getCourseName();//课程名称
                if (courseName == null) {
                    return;
                }
                int courseLength = coursedata.getCourseLength();//课程时长
                LoginUserBean userInfo1 = UserManger.getUserInfo();
                String userId1 = userInfo1.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sp.edit();
                //    editor.putString("duration", duration);
                editor.putInt("courseLength", courseLength);
                editor.commit();

                tv_courseName.setText(courseName);
                int stId = sp.getInt("stId", 0);
                if (stId == 500001) {
                    tv_courseLength.setVisibility(View.INVISIBLE);
                } else {
                    tv_courseLength.setVisibility(View.VISIBLE);
                    tv_courseLength.setText("课程时长:" + courseLength + "分钟");
                }


                //视频地址
                String accessVideoUrl = coursedata.getAccessVideoUrl();
                video(accessVideoUrl);

                //课长判断何久拍照
                photo(courseLength);
                //音频地址
                String accessAudioUrl = coursedata.getAccessAudioUrl();
                Audio(accessAudioUrl);

                //PDF文件解析
                String fileUrl = coursedata.getFileUrl();
                String fileName = coursedata.getFileName();
                if (fileUrl != null) {
                    mSuperFileView.setVisibility(View.VISIBLE);
                    mSuperFileView.setOnGetFilePathListener(new SuperFileView2.OnGetFilePathListener() {
                        @Override
                        public void onGetFilePath(SuperFileView2 mSuperFileView2) {
                            String path = FileParseUtil.getFilePath(mSuperFileView2, fileUrl, fileName);
                            if (path.contains("http")) {//网络地址要先下载
                                showAlertDialog(mSuperFileView2, fileUrl);
                            } else {
                                mSuperFileView2.displayFile(new File(path));
                            }
                        }
                    });
                    mSuperFileView.show();
                }


                String courseContent = coursedata.getCourseContent();
                if (courseContent != null) {
                    new Thread(new runn(courseContent)).start();
                }

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });


    }

    private String getNewContent(String htmltext) {
        Document doc = Jsoup.parse(htmltext);
        Elements elements = doc.getElementsByTag("img");
        for (Element element : elements) {
            element.attr("width", "100%").attr("height", "auto");
        }

        return doc.toString();
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Bundle data = msg.getData();
            String val = data.getString("value");
            String html = "<html><body>" + val + "</body></html>";
            web.loadDataWithBaseURL(null,
                    getNewContent(html), "text/html", "utf-8",
                    null);
        }
    };

    /**
     * 网络操作相关的子线程
     */
    public class runn implements Runnable {
        String vv;

        public runn(String vv) {
            this.vv = vv;
        }

        @Override
        public void run() {
            Message msg = new Message();
            Bundle data = new Bundle();
            data.putString("value", vv);
            msg.setData(data);
            handler.sendMessage(msg);
        }
    }


    private void Audio(String accessAudioUrl) {

        if (accessAudioUrl == null) {
            re_course2.setVisibility(View.GONE);

            return;
        }
        re_course2.setVisibility(View.VISIBLE);
        LoginUserBean userInfo1 = UserManger.getUserInfo();
        String userId1 = userInfo1.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int uschSn = sp.getInt("uschSn", 0);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("accessAudioUrl" + tcsn + uschSn, accessAudioUrl);
        editor.commit();

    }


    private void photo(int courseLength) {
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int minPer = sp.getInt("minPer", 0);
        int tcsn = sp.getInt("tcsn", 0);
        int readLength = sp.getInt("readLength", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
//        int num = (courseLength * 60 * minPer) / 100;
//        SharedPreferences.Editor editor = sp.edit();
//        //      editor.putString("duration", duration);
//        editor.putInt("num"+tcsn, num);
//        editor.commit();
        if (tphotoMark == 1) {
            SharedPreferences.Editor editor = sp.edit();
//            if(readLength>0)
//            {
//                int firsttime2 = (int) (readLength*60+20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
//                editor.putInt("intfirsttime2" + tcsn, firsttime2);
//                editor.commit();
//            }else{
//                int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//                int firsttime2 = (int) (80 + Math.random() * (30 - 20 + 1));//第二次验证拍照随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime1);
//                editor.putInt("intfirsttime2" + tcsn, firsttime2);
//                editor.commit();
//            }
            int num = (courseLength * 60 * minPer) / 100;
            editor.putInt("num" + tcsn, num);
            editor.commit();
        } else if (tphotoMark == 0) {
            int num = (courseLength * 60 * minPer) / 100;
            SharedPreferences.Editor editor = sp.edit();
            editor.putInt("num" + tcsn, num);
            editor.commit();
        } else if (tphotoMark == 2) {
            SharedPreferences.Editor editor = sp.edit();
//            if(readLength>0)
//            {
//
//                int firsttime2 = (int) (readLength*60+20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime2);
//                editor.commit();
//            }else{
//                int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime1);
//                editor.commit();
//            }
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;
                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
            } else {
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
            }
            editor.putInt("num" + tcsn, num);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.commit();
        } else if (tphotoMark == 3) {
            SharedPreferences.Editor editor = sp.edit();
//            if(readLength>0)
//            {
//
//                int firsttime2 = (int) (readLength*60+20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime2);
//                editor.commit();
//            }else{
//                int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime1);
//                editor.commit();
//            }
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;
                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 2);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数


            } else {
                course_time = num - readLength * 60;
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + (course_time / 2);//30秒到五分之四时间点的二分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
            }
            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.commit();
        } else if (tphotoMark == 4) {
            SharedPreferences.Editor editor = sp.edit();
//            if(readLength>0)
//            {
//
//                int firsttime2 = (int) (readLength*60+20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime2);
//                editor.commit();
//            }else{
//                int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime1);
//                editor.commit();
//            }
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int thirdpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;

                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 3);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) * 2 / 3);//30秒到五分之四时间点的二分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数

            } else {
                course_time = num - readLength * 60;
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart + 5) + Math.random() * 5);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + (course_time / 3);//30秒到五分之四时间点的三分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + (course_time * 2 / 3);//30秒到五分之四时间点的三分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数

            }
            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numthirdpart" + tcsn, thirdpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.commit();
        } else if (tphotoMark == 5) {
            SharedPreferences.Editor editor = sp.edit();
//            if(readLength>0)
//            {
//                int firsttime2 = (int) (readLength*60+20 + Math.random() * (30 - 20 + 1));//第二次验证拍照一分钟之后随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime2);
//                editor.commit();
//            }else{
//                int firsttime1 = (int) (20 + Math.random() * (30 - 20 + 1));//第一次拍照随机20秒到30秒
//                editor.putInt("intfirsttime" + tcsn, firsttime1);
//                editor.commit();
//            }
            int num = (courseLength * 60 * minPer) / 100;//最低学习时间
            int course_time = 0;
            int secondpart = 0;
            int thirdpart = 0;
            int fourpart = 0;
            int Fifthpart = 0;
            if (num < readLength * 60) {
                course_time = courseLength * 60 - readLength * 60;

                int numFifthpart = readLength * 60 + (course_time * 4) / 5;//五分四提示拍照
                Fifthpart = (int) ((numFifthpart - 5) + Math.random() * 10);//最后一张上下五秒钟随机数
                int numsecondpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 4);//30秒到五分之四时间点的四分之一提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                int numthirdpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) / 2);//30秒到五分之四时间点的二分之二提示拍照
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数
                int numfourpart = readLength * 60 + 30 + ((numFifthpart - (30 + readLength * 60)) * 3 / 4);//30秒到五分之四时间点的四分之三提示拍照
                fourpart = (int) ((numfourpart - 5) + Math.random() * 10);//第四张上下五秒钟随机数
            } else {
                course_time = num - readLength * 60;
                int numFifthpart = (num * 4) / 5;//五分四提示拍照
                int numsecondpart = readLength * 60 + (course_time / 4);//30秒到五分之四时间点的四分之一提示拍照
                int numthirdpart = readLength * 60 + (course_time / 2);//30秒到五分之四时间点的二分之二提示拍照
                int numfourpart = readLength * 60 + (course_time * 3 / 4);//30秒到五分之四时间点的四分之三提示拍照
                secondpart = (int) ((numsecondpart - 5) + Math.random() * 10);//第二张上下五秒钟随机数
                thirdpart = (int) ((numthirdpart - 5) + Math.random() * 10);//第三张上下五秒钟随机数
                fourpart = (int) ((numfourpart - 5) + Math.random() * 10);//第四张上下五秒钟随机数
                Fifthpart = (int) ((numFifthpart + 5) + Math.random() * 5);//最后一张上下五秒钟随机数
            }
            editor.putInt("num" + tcsn, num);
            editor.putInt("numsecondpart" + tcsn, secondpart);
            editor.putInt("numthirdpart" + tcsn, thirdpart);
            editor.putInt("numfourpart" + tcsn, fourpart);
            editor.putInt("numFifthpart" + tcsn, Fifthpart);
            editor.commit();
        }

    }


    private void video(String accessVideoUrl) {
        if (accessVideoUrl == null) {
            jcVideoPlayerStandard.setVisibility(View.GONE);
            return;
        }
        jcVideoPlayerStandard.setVisibility(View.VISIBLE);
        HashMap headers = new HashMap<String, String>();
        headers.put("Referer",AppInterfaceConfig.BASE_URL);
        JZDataSource jzDataSource=new JZDataSource(accessVideoUrl,"",headers);
        jcVideoPlayerStandard.setUp(jzDataSource,jcVideoPlayerStandard.SCREEN_NORMAL);
        //jcVideoPlayerStandard.setUp(accessVideoUrl, "", jcVideoPlayerStandard.SCREEN_NORMAL, JZMediaIjk.class);
//        jcVideoPlayerStandard.loop  = true;//是否循环播放
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int readLength = sp.getInt("readLength", 0);
        int stId = sp.getInt("stId", 0);
        //    int courseLength = sp.getInt("courseLength", 0);
        jcVideoPlayerStandard.seekToInAdvance = readLength * 60 * 1000;
        //   jcVideoPlayerStandard.startVideo();//自动播放
        Picasso.with(getApplicationContext()).load(R.mipmap.video)
                .into(jcVideoPlayerStandard.thumbImageView);
        JzvdStd.progressBar.setEnabled(false);

//        if(stId==500001) {
//            JzvdStd.progressBar.setEnabled(false);
//        }

//        JzvdStd.progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
//            @Override
//            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//                if(fromUser) {
//                    int tcsn = sp.getInt("tcsn", 0);
//                    int uschSn = sp.getInt("uschSn", 0);
//                    String format = sp.getString("format" + tcsn + uschSn, "");
//                    String[] splitformat = format.split(":");
//                    String format1 = splitformat[0];
//                    String format2 = splitformat[1];
//                    String format3 = splitformat[2];
//                    int iformat1 = Integer.valueOf(format1);//转int
//                    int iformat2 = Integer.valueOf(format2);//转int
//                    int iformat3 = Integer.valueOf(format3);//转int
//                    int formattime = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                    if (progress> formattime*100/(courseLength*60)) {
//                        LogUtils.e("进度值", progress  + "-" + formattime*100/(courseLength*60));
//                        seekBar.setEnabled(false);
//                    } else {
//                        LogUtils.e("进度值", progress  + "-" + formattime*100/(courseLength*60));
//                        seekBar.setEnabled(true);
//                    }
//                }
//            }
//            @Override
//            public void onStartTrackingTouch(SeekBar seekBar) {
//            }
//
//            @Override
//            public void onStopTrackingTouch(SeekBar seekBar) {
//            }
//        });

    }


    @SuppressLint("HandlerLeak")
    private void initDialog() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        LinearLayout le_takepicture = (LinearLayout) contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);
            }
        });

//        mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                // popupWindow隐藏时恢复屏幕正常透明度
//                setBackgroundAlpha(1.0f);
//            }
//        });
//        setBackgroundAlpha(0.35f);//设置屏幕透明度
//        mPopWindow.setBackgroundDrawable(new BitmapDrawable());
        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第二张
    @SuppressLint("HandlerLeak")
    private void initDialog3() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 2);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第三张
    @SuppressLint("HandlerLeak")
    private void initDialog4() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 3);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第四张
    @SuppressLint("HandlerLeak")
    private void initDialog5() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 4);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    //拍照第五张
    @SuppressLint("HandlerLeak")
    private void initDialog6() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.course_popwindowlayout, null);
        mPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        //倒计时
        downtime = (TextView) contentView.findViewById(R.id.tv_photo3);
        tv_photo2 = (TextView) contentView.findViewById(R.id.tv_photo2);
        tv_photo4 = (TextView) contentView.findViewById(R.id.tv_photo4);
        tv_photo1 = (TextView) contentView.findViewById(R.id.tv_photo1);
        tv_photo = (TextView) contentView.findViewById(R.id.tv_photo);
        img_photo = (ImageView) contentView.findViewById(R.id.img_photo);
        TextPaint paint = downtime.getPaint();
        paint.setFakeBoldText(true);//字体加粗
        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        //    LinearLayout le_takepicture = (LinearLayout)contentView.findViewById(R.id.le_takepicture);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mOffTime.cancel();
                timerTask.cancel();
                mPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 5);
            }
        });

        mPopWindow.setFocusable(false);
        mPopWindow.setOutsideTouchable(false);
        mPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);
        //////倒计时
        mOffTime = new Timer(true);
        TimerTask tt = new TimerTask() {
            int countTime = 15;

            public void run() {
                if (countTime > 0) {
                    countTime--;
                }
                Message msg = new Message();
                msg.what = countTime;
                mOffHandler.sendMessage(msg);

            }
        };
        mOffTime.schedule(tt, 1000, 1000);
    }

    @SuppressLint("HandlerLeak")
    private void initDialog2() {
        if (tv_playorpause.getText().toString().trim().equals("播放")) {
            pause();
        }
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.test_popwindowlayout, null);
        mPopWindow2 = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);


        ImageView takepciture = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        LinearLayout le_takepicture = (LinearLayout) contentView.findViewById(R.id.le_takepicture1);//跟布局
        takepciture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mPopWindow2.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int stId = sp.getInt("stId", 0);
                String photoUrl = sp.getString("photoUrl", "");
                Bundle bundle = new Bundle();
                bundle.putInt("stId", stId);
                bundle.putString("photoUrl", photoUrl);
                startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);
            }
        });

//        mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                // popupWindow隐藏时恢复屏幕正常透明度
//                setBackgroundAlpha(1.0f);
//            }
//        });
//        setBackgroundAlpha(0.35f);//设置屏幕透明度
//        mPopWindow.setBackgroundDrawable(new BitmapDrawable());
        mPopWindow2.setFocusable(false);
        mPopWindow2.setOutsideTouchable(false);
        mPopWindow2.showAtLocation(le_takepicture, Gravity.CENTER, 0, 0);

    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (mPopWindow != null && mPopWindow.isShowing()) {
            return false;
        }
        if (mSorryPopWindow != null && mSorryPopWindow.isShowing()) {
            return false;
        }
        if (mStopPopWindow != null && mStopPopWindow.isShowing()) {
            return false;
        }
        if (mPopWindow2 != null && mPopWindow2.isShowing()) {
            return false;
        }

        return super.dispatchTouchEvent(event);
    }

    private void ShowSorryPopwindow() {

        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.sorry_popwindowlayout, null);
        mSorryPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
        LinearLayout le_sorry = (LinearLayout) contentView.findViewById(R.id.le_sorry);//跟布局
        ImageView sorry_exit = (ImageView) contentView.findViewById(R.id.sorry_img_photo1);//退出
        sorry_exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mSorryPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tcsn = sp.getInt("tcsn", 0);
                int uschSn = sp.getInt("uschSn", 0);
                SharedPreferences.Editor edit = sp.edit();
                edit.remove("format" + tcsn + uschSn);
                edit.commit();
                Thread thread2 = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                        mHandler.sendEmptyMessage(0);
                    }
                });
                thread2.start();


            }
        });
//        mSorryPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                // popupWindow隐藏时恢复屏幕正常透明度
//                setBackgroundAlpha(1.0f);
//            }
//        });
//        setBackgroundAlpha(0.35f);//设置屏幕透明度
//        mSorryPopWindow.setBackgroundDrawable(new BitmapDrawable());
        mSorryPopWindow.setFocusable(false);
        mSorryPopWindow.setOutsideTouchable(false);
        mSorryPopWindow.showAtLocation(le_sorry, Gravity.CENTER, 0, 0);

    }

    @Override
    public void onBackPressed() {
        if (Jzvd.backPress()) {
            return;
        }
//        LoginUserBean userInfo = UserManger.getUserInfo();
//        String userId = userInfo.getData().getUserId();
//        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
//                Context.MODE_PRIVATE);
//        int tcsn = sp.getInt("tcsn", 0);
//        int uschSn = sp.getInt("uschSn", 0);
//        String formatime = sp.getString("format" + tcsn+uschSn, "");
//        String firsttime = sp.getString("firsttime" + tcsn, "");
//        if (formatime.equals(firsttime)) {
//            Toast.makeText(LearnthemticlearningDetailsActivity.this, "拍照期间暂时不能退出当前界面", Toast.LENGTH_LONG).show();
//        } else {
        /*if(stId== 510016 || stId== 510017 || stId== 510018 || stId== 510019) {  //四川专题
            //HelpUtil.showTiShiDialog(LearnthemticlearningDetailsActivity.this,"该专题课程未学完将不会保存学习记录");
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(LearnthemticlearningDetailsActivity.this);
            builder1.setMessage("该专题课程未学完将不会保存学习记录");
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.clear();
                    edit.commit();
                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;
                    finish();
                }
            });
            builder1.create().show();
            return;
        }*/
        LoginUserBean userInfo2 = UserManger.getUserInfo();
        String userId3 = userInfo2.getData().getUserId();
        SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId3,
                Context.MODE_PRIVATE);
        int tcsn = sp1.getInt("tcsn", 0);
        int uschSn = sp1.getInt("uschSn", 0);
        int courseLength2 = sp1.getInt("courseLength", 0);
        int sn2 = sp1.getInt("sn", 0);
        String formats2 = sp1.getString("format" + tcsn + uschSn, "");
        String[] splitformat2 = formats2.split(":");
        String formatstr7 = splitformat2[0];
        String formatstr8 = splitformat2[1];
        String formatstr9 = splitformat2[2];
        int iformat7 = Integer.valueOf(formatstr7);//转int
        int iformat8 = Integer.valueOf(formatstr8);//转int
        int iformat9 = Integer.valueOf(formatstr9);//转int
        int formattime2 = iformat7 * 3600 + iformat8 * 60 + iformat9 * 1;
        if (formattime2 < 60) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
            TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
            tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
            TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
            TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
            btn_sure.setText("确认退出");
            btn_cancel.setText("继续学习");
            final AlertDialog dialog = builder.create();
            dialog.show();
            dialog.getWindow().setContentView(view1);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            btn_sure.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.clear();
                    edit.commit();

                    timerTask.cancel();
                    timer1.cancel();
                    timerTask = null;
                    timer1 = null;
                    finish();
                    //设置你的操作事项
                }
            });

            btn_cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    dialog.dismiss();
                }
            });
        } else {//满一分钟保存
            if (formattime2 >= courseLength2 * 60) {
                if (rowscourseList.size() != 0) {
                    for (int i = 0; i < rowscourseList.size(); i++) {
                        if (rowscourseList.get(i).isSelect() == false) {
                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                            builder1.setMessage("第" + (i + 1) + "测验题未答，请答题");
                            builder1.setTitle("提示:");
                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    ;
                                    //设置你的操作事项
                                }
                            });
                            builder1.create().show();
                            return;
                        } else {
                            if (rowscourseList.get(i).isLOOP() == false) {
                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(this);
                                builder1.setMessage("第" + (i + 1) + "测验题回答错误，请重新答题");
                                builder1.setTitle("提示:");
                                builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        ;
                                        //设置你的操作事项
                                    }
                                });
                                builder1.create().show();
                                return;
                            }
                        }
                    }
                }
                int tphotoMark = sp1.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    //有题目调提交接口
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("")) {
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList,  3);
                    } else {
                        initsavedata(uschSn, sn2, tcsn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 0) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //   String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttime);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                    mProgressDialog.setMessage("提交中...");
                    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                    mProgressDialog.setCancelable(false);
                    mProgressDialog.show();
                    //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                    userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList,  3);
                } else if (tphotoMark == 2) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog();
//                            return;
//                        }
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog3();
//                            return;
//                        }
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("")) {
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList,  3);
                    } else {
                        initsavedata(uschSn, sn2, tcsn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 3) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog();
//                            return;
//                        }
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog3();
//                            return;
//                        }
//                        if (imgurl2.equals("")) {
//                            timerTask.cancel();
//                            initDialog4();
//                            return;
//                        }
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstr1 = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numFifthpartstr1);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("")) {
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, 3);
                    } else {
                        initsavedata(uschSn, sn2, tcsn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 4) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
                    String imgurl3 = sp1.getString("imgurl3" + tcsn + uschSn, "");
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog();
//                            return;
//                        }
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog3();
//                            return;
//                        }
//                        if (imgurl2.equals("")) {
//                            timerTask.cancel();
//                            initDialog4();
//                            return;
//                        }
//                        if (imgurl3.equals("")) {
//                            timerTask.cancel();
//                            initDialog5();
//                            return;
//                        }
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第二次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstrsub);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numFifthpartstrsub);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("") && !imgurl3.equals("")) {
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList,  3);
                    } else {
                        initsavedata(uschSn, sn2, tcsn, courseLength2, photoList);
                    }
                } else if (tphotoMark == 5) {
                    String imgurl = sp1.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl1 = sp1.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl2 = sp1.getString("imgurl2" + tcsn + uschSn, "");
                    String imgurl3 = sp1.getString("imgurl3" + tcsn + uschSn, "");
                    String imgurl4 = sp1.getString("imgurl4" + tcsn + uschSn, "");
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog();
//                            return;
//                        }
//                        if (imgurl1.equals("")) {
//                            timerTask.cancel();
//                            initDialog3();
//                            return;
//                        }
//                        if (imgurl2.equals("")) {
//                            timerTask.cancel();
//                            initDialog4();
//                            return;
//                        }
//                        if (imgurl3.equals("")) {
//                            timerTask.cancel();
//                            initDialog5();
//                            return;
//                        }
//                        if (imgurl4.equals("")) {
//                            timerTask.cancel();
//                            initDialog6();
//                            return;
//                        }
                    String firsttime = sp1.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr = sp1.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstr = sp1.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String numfourpartstr = sp1.getString("numfourpartstr" + tcsn, "");//第四次抓拍时间
                    String numFifthpartstr = sp1.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间
                    String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numsecondpartstrsub = numsecondpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numthirdpartstrsub = numthirdpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numfourpartstrsub = numfourpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    String numFifthpartstrsub = numFifthpartstr.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl);
                    userTcPhoto.setSnapTime(firsttimesub);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    userTcPhoto1.setUrl(imgurl1);
                    userTcPhoto1.setSnapTime(numsecondpartstrsub);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    userTcPhoto2.setUrl(imgurl2);
                    userTcPhoto2.setSnapTime(numthirdpartstrsub);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    userTcPhoto3.setUrl(imgurl3);
                    userTcPhoto3.setSnapTime(numfourpartstrsub);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    userTcPhoto4.setUrl(imgurl4);
                    userTcPhoto4.setSnapTime(numFifthpartstrsub);
                    photoList.add(userTcPhoto);
                    photoList.add(userTcPhoto1);
                    photoList.add(userTcPhoto2);
                    photoList.add(userTcPhoto3);
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    if (!imgurl.equals("") && !imgurl1.equals("") && !imgurl2.equals("") && !imgurl3.equals("") && !imgurl4.equals("")) {
                        mProgressDialog = new ProgressDialog(LearnthemticlearningDetailsActivity.this, ProgressDialog.THEME_HOLO_DARK);
                        mProgressDialog.setMessage("提交中...");
                        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                        mProgressDialog.setCancelable(false);
                        mProgressDialog.show();
                        //new Login().getSureSpeciedcourse(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, this, 3);
                        userStCourseSave(uschSn, sn2, tcsn, courseLength2, 1,mac,stId, photoList, 3);
                    } else {
                        initsavedata(uschSn, sn2, tcsn, courseLength2, photoList);
                    }
                }
            } else if (formattime2 < courseLength2 * 60) {
                LoginUserBean userInfo1 = UserManger.getUserInfo();
                String userId1 = userInfo1.getData().getUserId();
                SharedPreferences sp2 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                        Context.MODE_PRIVATE);
                int tcsn2 = sp2.getInt("tcsn", 0);
                int uschSn2 = sp2.getInt("uschSn", 0);
                int sn = sp2.getInt("sn", 0);

                int readLength = (formattime2 % 60 == 0) ? formattime2 / 60 : (formattime2 / 60);//累计学习时间
                //   int readLength = (formattime2 % 60 != 0) ? formattime2 / 60 + 1 : (formattime2 / 60);//累计学习时间
                int tphotoMark = sp2.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {
                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                } else if (tphotoMark == 0) {
                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimestr);
                    userTcPhoto.setUrl(imgurl1);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                } else if (tphotoMark == 2) {
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第二次抓拍时间
                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //    String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                } else if (tphotoMark == 3) {
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第三次抓拍时间

                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //    String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //   String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                } else if (tphotoMark == 4) {
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numthirdpartstrstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                    String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第四次抓拍时间

                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    String imgurl4 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstrstr1sub = numthirdpartstrstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                } else if (tphotoMark == 5) {
                    String firsttimestr = sp2.getString("firsttime" + tcsn2, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp2.getString("numsecondpartstr" + tcsn2, "");//第二次抓拍时间
                    String numthirdpartstr1 = sp2.getString("numthirdpartstr" + tcsn2, "");//第三次抓拍时间
                    String numfourpartstr1 = sp2.getString("numfourpartstr" + tcsn2, "");//第三次抓拍时间
                    String numFifthpartstr1 = sp2.getString("numFifthpartstr" + tcsn2, "");//第五次抓拍时间

                    String imgurl1 = sp2.getString("imgurl" + tcsn2 + uschSn2, "");
                    String imgurl2 = sp2.getString("imgurl1" + tcsn2 + uschSn2, "");
                    String imgurl3 = sp2.getString("imgurl2" + tcsn2 + uschSn2, "");
                    String imgurl4 = sp2.getString("imgurl3" + tcsn2 + uschSn2, "");
                    String imgurl5 = sp2.getString("imgurl4" + tcsn2 + uschSn2, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstrstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numfourpartstr1sub);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    if (imgurl5.equals("")) {
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        userTcPhoto4.setUrl(imgurl5);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto4.setUrl(imgurl5);
                    }
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata(uschSn2, sn, tcsn2, readLength, photoList);
                }
            }
        }
//                });
//
//            }
        //     }

        //       super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (sensorManager != null) {
            sensorManager.unregisterListener(sensorEventListener);
        }

//        JZVideoPlayer jzvd = JZVideoPlayerManager.getCurrentJzvd();
//        if(jzvd!=null)
//        {
//            jzvd.onStatePause();
//            JZMediaManager.pause();//暂停
//
//        }else{
//            JZVideoPlayer.releaseAllVideos();
//
//        }
        Jzvd.resetAllVideos();
        /**
         * 记得释放camera，方便其他应用调用
         */
        //  releaseCamera();
    }

    @SuppressLint("HandlerLeak")
    private void initStopDialog() {
        //设置contentView
        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.stop_popwindowlayout, null);
        mStopPopWindow = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
        ImageView takepciture1 = (ImageView) contentView.findViewById(R.id.img_photo1);//点拍照
        takepciture1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ishave = false;
                mStopPopWindow.dismiss();
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                int tphotoMark = sp.getInt("tphotoMark", 0);
                if (tphotoMark == 1) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(0);
                        }
                    });
                    thread.start();
                } else if (tphotoMark == 0) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(2);
                        }
                    });
                    thread.start();


                } else if (tphotoMark == 2) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(3);
                        }
                    });
                    thread.start();


                } else if (tphotoMark == 3) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(4);
                        }
                    });
                    thread.start();


                } else if (tphotoMark == 4) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(5);
                        }
                    });
                    thread.start();


                } else if (tphotoMark == 5) {

                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                            mHandler.sendEmptyMessage(6);
                        }
                    });
                    thread.start();


                }


            }
        });

        mStopPopWindow.setFocusable(false);
        mStopPopWindow.setOutsideTouchable(false);
        mStopPopWindow.showAtLocation(le_parement, Gravity.CENTER, 0, 0);

    }

    //退出后台
    @Override
    protected void onStop() {
        super.onStop();

//        if (timerTask != null) {
//            timerTask.cancel();
//            if(ishave)
//            {
//                ishave =false;
//            }else{
//                ishave =true;
//            }
//
//
//
//            }
        resave();//自动保存

    }

    public void resave() {
        //退出小窗口保存
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int uschSn = sp.getInt("uschSn", 0);
        int sn = sp.getInt("sn", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
        String formats2 = sp.getString("format" + tcsn + uschSn, "");
        if (!formats2.equals("")) {
            String[] splitformat2 = formats2.split(":");
            String formatstr7 = splitformat2[0];
            String formatstr8 = splitformat2[1];
            String formatstr9 = splitformat2[2];
            int iformat7 = Integer.valueOf(formatstr7);//转int
            int iformat8 = Integer.valueOf(formatstr8);//转int
            int iformat9 = Integer.valueOf(formatstr9);//转int
            int formattime2 = iformat7 * 3600 + iformat8 * 60 + iformat9 * 1;
            if (formattime2 >= 60) {

                int readLength = (formattime2 % 60 == 0) ? formattime2 / 60 : (formattime2 / 60);//累计学习时间
                // int readLength = (formattime2 % 60 != 0) ? formattime2 / 60 +1: (formattime2 / 60);//累计学习时间
                LogUtils.e("readLength", readLength + "");
                if (tphotoMark == 1) {
                    String imgurl = sp.getString("imgurl" + tcsn + uschSn, "");
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimesub);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                } else if (tphotoMark == 0) {
                    String imgurl = sp.getString("imgurl" + tcsn + uschSn, "");
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    //  String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setSnapTime(firsttimestr);
                    userTcPhoto.setUrl(imgurl);
                    photoList.add(userTcPhoto);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                } else if (tphotoMark == 2) {
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                    String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //  String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numFifthpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                } else if (tphotoMark == 3) {
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间

                    String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //      String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //     String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numFifthpartstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                } else if (tphotoMark == 4) {
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstrstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间

                    String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                    String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstrstr1sub = numthirdpartstrstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numFifthpartstr1);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                } else if (tphotoMark == 5) {
                    String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                    String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                    String numthirdpartstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                    String numfourpartstr1 = sp.getString("numfourpartstr" + tcsn, "");//第三次抓拍时间
                    String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间

                    String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                    String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                    String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                    String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                    String imgurl5 = sp.getString("imgurl4" + tcsn + uschSn, "");
                    String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                    //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                    List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                    UserTcPhoto userTcPhoto = new UserTcPhoto();
                    userTcPhoto.setUrl(imgurl1);
                    userTcPhoto.setSnapTime(firsttimesub);
                    photoList.add(userTcPhoto);
                    UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                    if (imgurl2.equals("")) {
                        userTcPhoto1.setSnapTime(numsecondpartstr1);
                        userTcPhoto1.setUrl(imgurl2);

                    } else {
                        String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                        userTcPhoto1.setUrl(imgurl2);
                    }
                    photoList.add(userTcPhoto1);
                    UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                    if (imgurl3.equals("")) {
                        userTcPhoto2.setSnapTime(numthirdpartstr1);
                        userTcPhoto2.setUrl(imgurl3);

                    } else {
                        String numthirdpartstrstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                        userTcPhoto2.setUrl(imgurl3);
                    }
                    photoList.add(userTcPhoto2);
                    UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                    if (imgurl4.equals("")) {
                        userTcPhoto3.setSnapTime(numfourpartstr1);
                        userTcPhoto3.setUrl(imgurl4);

                    } else {
                        String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto3.setSnapTime(numfourpartstr1sub);
                        userTcPhoto3.setUrl(imgurl4);
                    }
                    photoList.add(userTcPhoto3);
                    UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                    if (imgurl5.equals("")) {
                        userTcPhoto4.setSnapTime(numFifthpartstr1);
                        userTcPhoto4.setUrl(imgurl5);

                    } else {
                        String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                        userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                        userTcPhoto4.setUrl(imgurl5);
                    }
                    photoList.add(userTcPhoto4);
                    Gson gson = new Gson();
                    String strphotoList = gson.toJson(photoList);
                    LogUtils.e("strphotoList", strphotoList);
                    initsavedata1(uschSn, sn, tcsn, readLength, photoList);
                }
            }
        }
    }


    //重启前台
    @Override
    protected void onRestart() {
        super.onRestart();
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId1 = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                Context.MODE_PRIVATE);
        int tcsn1 = sp.getInt("tcsn", 0);
        int tag = sp.getInt("tag" + tcsn1, 0);
        if (tag == 0) {
            int uschSn1 = sp.getInt("uschSn", 0);
            String formats1 = sp.getString("format" + tcsn1 + uschSn1, "");
            String[] splitformat1 = formats1.split(":");
            String formatstr1 = splitformat1[0];
            String formatstr2 = splitformat1[1];
            String formatstr3 = splitformat1[2];
            int iformat4 = Integer.valueOf(formatstr1);//转int
            int iformat5 = Integer.valueOf(formatstr2);//转int
            int iformat6 = Integer.valueOf(formatstr3);//转int
            int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
            if (formattime1 < 60) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您本次学习未满一分钟，无法保存学习进度，退出后将重新学习本课程。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.clear();
                        edit.commit();
                        timerTask.cancel();
                        timer1.cancel();
                        timerTask = null;
                        timer1 = null;
                        finish();
                        //设置你的操作事项
                    }
                });
                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();


                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId1 = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putInt("tag" + tcsn, 0);
                        edit.commit();
                    }
                });
            } else {//滿一分鐘保存
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View view1 = View.inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                TextView tv_message = (TextView) view1.findViewById(R.id.message);//输入内容
                tv_message.setText("您的学习进度已保存，下次进入将继续本课程的学习。");
                TextView btn_sure = (TextView) view1.findViewById(R.id.positiveButton);
                TextView btn_cancel = (TextView) view1.findViewById(R.id.negativeButton);
                btn_sure.setText("确认退出");
                btn_cancel.setText("继续学习");
                final AlertDialog dialog = builder.create();
                dialog.show();
                dialog.getWindow().setContentView(view1);
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                dialog.setCancelable(false);
                btn_sure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int sn = sp.getInt("sn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String formats1 = sp.getString("format" + tcsn + uschSn, "");
                        String[] splitformat1 = formats1.split(":");
                        String formatstr1 = splitformat1[0];
                        String formatstr2 = splitformat1[1];
                        String formatstr3 = splitformat1[2];
                        int iformat4 = Integer.valueOf(formatstr1);//转int
                        int iformat5 = Integer.valueOf(formatstr2);//转int
                        int iformat6 = Integer.valueOf(formatstr3);//转int
                        int formattime1 = iformat4 * 3600 + iformat5 * 60 + iformat6 * 1;
                        int readLength = (formattime1 % 60 == 0) ? formattime1 / 60 : (formattime1 / 60);//累计学习时间
                        //  int readLength = (formattime1 % 60 != 0) ? formattime1 / 60+1 : (formattime1 / 60);//累计学习时间
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        if (tphotoMark == 1) {
                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                            //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttimesub);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        } else if (tphotoMark == 0) {
                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String firsttime = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            //  String firsttimesub = firsttime.substring(3, 8);//截取字符串00:00:00变成00:00
                            //                     String durationsub = duration.substring(3, 8);//截取字符串00:00:00变成00:00
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setSnapTime(firsttime);
                            userTcPhoto.setUrl(imgurl1);
                            photoList.add(userTcPhoto);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        } else if (tphotoMark == 2) {
                            String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第二次抓拍时间
                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                            //  String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setUrl(imgurl1);
                            userTcPhoto.setSnapTime(firsttimesub);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numFifthpartstr1);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numFifthpartstr1sub);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        } else if (tphotoMark == 3) {
                            String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第三次抓拍时间

                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                            String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                            //       String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            //      String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setUrl(imgurl1);
                            userTcPhoto.setSnapTime(firsttimesub);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numFifthpartstr1);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numFifthpartstr1sub);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        } else if (tphotoMark == 4) {
                            String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String numthirdpartstrstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                            String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第四次抓拍时间

                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                            String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                            String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                            //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setUrl(imgurl1);
                            userTcPhoto.setSnapTime(firsttimesub);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numthirdpartstrstr1);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numthirdpartstrstr1sub = numthirdpartstrstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);
                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                            if (imgurl4.equals("")) {
                                userTcPhoto3.setSnapTime(numFifthpartstr1);
                                userTcPhoto3.setUrl(imgurl4);

                            } else {
                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto3.setSnapTime(numFifthpartstr1sub);
                                userTcPhoto3.setUrl(imgurl4);
                            }
                            photoList.add(userTcPhoto3);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        } else if (tphotoMark == 5) {
                            String firsttimestr = sp.getString("firsttime" + tcsn, "");//第一次抓拍时间
                            String numsecondpartstr1 = sp.getString("numsecondpartstr" + tcsn, "");//第二次抓拍时间
                            String numthirdpartstr1 = sp.getString("numthirdpartstr" + tcsn, "");//第三次抓拍时间
                            String numfourpartstr1 = sp.getString("numfourpartstr" + tcsn, "");//第三次抓拍时间
                            String numFifthpartstr1 = sp.getString("numFifthpartstr" + tcsn, "");//第五次抓拍时间

                            String imgurl1 = sp.getString("imgurl" + tcsn + uschSn, "");
                            String imgurl2 = sp.getString("imgurl1" + tcsn + uschSn, "");
                            String imgurl3 = sp.getString("imgurl2" + tcsn + uschSn, "");
                            String imgurl4 = sp.getString("imgurl3" + tcsn + uschSn, "");
                            String imgurl5 = sp.getString("imgurl4" + tcsn + uschSn, "");
                            String firsttimesub = firsttimestr.substring(3, 8);//截取字符串00:00:00变成00:00
                            //         String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            //          String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                            List<UserTcPhoto> photoList = new ArrayList<UserTcPhoto>();
                            UserTcPhoto userTcPhoto = new UserTcPhoto();
                            userTcPhoto.setUrl(imgurl1);
                            userTcPhoto.setSnapTime(firsttimesub);
                            photoList.add(userTcPhoto);
                            UserTcPhoto userTcPhoto1 = new UserTcPhoto();
                            if (imgurl2.equals("")) {
                                userTcPhoto1.setSnapTime(numsecondpartstr1);
                                userTcPhoto1.setUrl(imgurl2);

                            } else {
                                String numsecondpartstr1sub = numsecondpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto1.setSnapTime(numsecondpartstr1sub);
                                userTcPhoto1.setUrl(imgurl2);
                            }
                            photoList.add(userTcPhoto1);
                            UserTcPhoto userTcPhoto2 = new UserTcPhoto();
                            if (imgurl3.equals("")) {
                                userTcPhoto2.setSnapTime(numthirdpartstr1);
                                userTcPhoto2.setUrl(imgurl3);

                            } else {
                                String numthirdpartstrstr1sub = numthirdpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto2.setSnapTime(numthirdpartstrstr1sub);
                                userTcPhoto2.setUrl(imgurl3);
                            }
                            photoList.add(userTcPhoto2);
                            UserTcPhoto userTcPhoto3 = new UserTcPhoto();
                            if (imgurl4.equals("")) {
                                userTcPhoto3.setSnapTime(numfourpartstr1);
                                userTcPhoto3.setUrl(imgurl4);

                            } else {
                                String numfourpartstr1sub = numfourpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto3.setSnapTime(numfourpartstr1sub);
                                userTcPhoto3.setUrl(imgurl4);
                            }
                            photoList.add(userTcPhoto3);
                            UserTcPhoto userTcPhoto4 = new UserTcPhoto();
                            if (imgurl5.equals("")) {
                                userTcPhoto4.setSnapTime(numFifthpartstr1);
                                userTcPhoto4.setUrl(imgurl5);

                            } else {
                                String numFifthpartstr1sub = numFifthpartstr1.substring(3, 8);//截取字符串00:00:00变成00:00
                                userTcPhoto4.setSnapTime(numFifthpartstr1sub);
                                userTcPhoto4.setUrl(imgurl5);
                            }
                            photoList.add(userTcPhoto4);
                            Gson gson = new Gson();
                            String strphotoList = gson.toJson(photoList);
                            LogUtils.e("strphotoList", strphotoList);
                            initsavedata(uschSn, sn, tcsn, readLength, photoList);
                        }
                        //设置你的操作事项
                    }
                });

                btn_cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        dialog.dismiss();
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId1 = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId1,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putInt("tag" + tcsn, 0);
                        edit.commit();
                    }
                });
            }
        } else {
            SharedPreferences.Editor edit = sp.edit();
            edit.putInt("tag" + tcsn1, 0);
            edit.commit();
        }


//        LoginUserBean userInfo = UserManger.getUserInfo();
//        String userId = userInfo.getData().getUserId();
//        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
//                Context.MODE_PRIVATE);
//        int tcsn = sp.getInt("tcsn", 0);
//        int uschSn = sp.getInt("uschSn", 0);
//        int tag = sp.getInt("tag" + tcsn, 0);
//        if (tag == 1) {
//            SharedPreferences.Editor edit = sp.edit();
//            edit.putInt("tag" + tcsn, 0);
//            edit.commit();
//            ishave=false;
//        } else if (tag == 0) {
//            String formatime = sp.getString("format" + tcsn+uschSn, "");
//            String firsttime = sp.getString("firsttime" + tcsn, "");
//            if(!firsttime.equals("")) {
//                String[] splitformat = formatime.split(":");
//                String formatstr1 = splitformat[0];
//                String formatstr2 = splitformat[1];
//                String formatstr3 = splitformat[2];
//                int iformat1 = Integer.valueOf(formatstr1);//转int
//                int iformat2 = Integer.valueOf(formatstr2);//转int
//                int iformat3 = Integer.valueOf(formatstr3);//转int
//                int formattime1 = iformat1 * 3600 + iformat2 * 60 + iformat3 * 1;
//                String[] splitformat1 = firsttime.split(":");
//                String formatstr4 = splitformat1[0];
//                String formatstr5 = splitformat1[1];
//                String formatstr6 = splitformat1[2];
//                int iformat4 = Integer.valueOf(formatstr4);//转int
//                int iformat5 = Integer.valueOf(formatstr5);//转int
//                int iformat6 = Integer.valueOf(formatstr6);//转int
//                int firsttime1 = (iformat4 * 3600 + iformat5 * 60 + iformat6 * 1);
//                if (formattime1 != firsttime1) {
//                    if (ishave) {
//                        initStopDialog();
//                        ishave = true;
//                    } else {
//                        ishave = true;
//                    }
//                } else {
//                    //  tv_pause.setVisibility(View.GONE);
//                }
//            }else{//无照片情况判断
//                if (ishave) {
//                    initStopDialog();
//                    ishave = true;
//                } else {
//                    ishave = true;
//                }
//            }
//        } else if(tag == 2)
//        {
//            SharedPreferences.Editor edit = sp.edit();
//            edit.putInt("tag" + tcsn, 3);
//            edit.commit();
//            ishave=false;
//        }else if(tag == 3)
//        {
//            if(ishave)
//            {
//                // initStopDialog();
//                ishave =true;
//            }else{
//                ishave =true;
//            }
//
//        }
    }

    @Override
    public void onStart() {
        super.onStart();
//        if (this.checkCameraHardware(this) && (mCamera == null)) {
//            // 打开camera
//            mCamera = getCamera();
//            if (mHolder != null) {
//                setStartPreview(mCamera, mHolder);
//            }
//        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        //摄像头
//        int cameraCount = 1;
//        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
//        cameraCount = Camera.getNumberOfCameras();// 得到摄像头的个数
//
//        for (int i = 0; i < cameraCount; i++) {
//            Camera.getCameraInfo(i, cameraInfo);// 得到每一个摄像头的信息
//            // 现在是后置，变更为前置
//            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
//                /**
//                 * 记得释放camera，方便其他应用调用
//                 */
//                releaseCamera();
//                // 打开当前选中的摄像头
//                mCamera = Camera.open(i);
//                //   mCamera.setDisplayOrientation(90);//旋转度数
//                // 通过surfaceview显示取景画面
//                setStartPreview(mCamera, mHolder);
//
//            }
//        }


    }
//    private Camera getCamera() {
//        Camera camera = null;
//        try {
//            camera = Camera.open();
//        } catch (Exception e) {
//            // Camera is not available (in use or does not exist)
//            camera = null;
//            LogUtils.e(TAG, "Camera is not available (in use or does not exist)");
//        }
//        return camera;
//    }


    @Override
    public void onDestroy() {
        super.onDestroy();

        FileParseUtil.releaseFileView();

        if (mPopWindow != null) {

            mPopWindow.dismiss();
        }
        if (mSorryPopWindow != null) {

            mSorryPopWindow.dismiss();
        }
        if (mPopWindow2 != null) {

            mPopWindow2.dismiss();
        }
        if (mStopPopWindow != null) {

            mStopPopWindow.dismiss();
        }
        if (mProgressDialog != null) {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
        mHandler.removeCallbacksAndMessages(null);
        mOffHandler.removeCallbacksAndMessages(null);
        musicHandler.removeMessages(0);//语音播放器释放
        mediaPlayer.release();//语音播放器释放资源
        EventBus.getDefault().unregister(this);//反注册EventBus
        Jzvd.resetAllVideos();
        SharedPreferences sp = getSharedPreferences("CameraSwitchView",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.clear();
        editor.commit();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(MessageEvent event) {
        String imgurl = event.getMessage();
        String messageurl = event.getMessageurl();
        int faceRecgMark = event.getFaceRecgMark();
        boolean isphoto = event.isIsphoto();
        int code = event.getCode();
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        int tcsn = sp.getInt("tcsn", 0);
        int uschSn = sp.getInt("uschSn", 0);
        int tphotoMark = sp.getInt("tphotoMark", 0);
        LogUtils.e("测试", "onEventMainThread: "+faceRecgMark+" "+isphoto+" "+code );
        //if (faceRecgMark == 500001) {
         if(faceRecgMark==1||faceRecgMark==2){
            if (isphoto) {
                Toasty.success(this, "人脸识别成功！", Toast.LENGTH_SHORT, true).show();
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    show_camera_iv.setWillNotDraw(false);
                    show_camera_iv.setContentDescription(messageurl);
                    Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                    show_camera_iv.setImageBitmap(bitmapByUrl);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + uschSn, imgurl);
                    edit.commit();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable() == null) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, imgurl);
                        edit.commit();
                    }
                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setWillNotDraw(false);
                        show_camera_iv1.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv1.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setWillNotDraw(false);
                        show_camera_iv2.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv2.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setWillNotDraw(false);
                        show_camera_iv3.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv3.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv4.setWillNotDraw(false);
                        show_camera_iv4.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv4.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + uschSn, imgurl);
                        edit.commit();
                    }
                }
            } else {
                timerTask.cancel();
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    show_camera_iv.setImageResource(R.mipmap.tongming);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + uschSn, "");
                    edit.commit();

                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();

                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();

                    }

                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, "");
                        edit.commit();

                    }

                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, "");
                        edit.commit();

                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable() != null && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv4.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + uschSn, "");
                        edit.commit();

                    }
                }

                if (code == 1) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("非常抱歉，您还没有上传个人头像，我们无法对您对你进行人脸识别。");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_cancel.setVisibility(View.GONE);
                    btn_sure.setText("上传头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            edit.remove("imgurl" + tcsn + uschSn);
                            edit.remove("imgurl1" + tcsn + uschSn);
                            edit.remove("imgurl2" + tcsn + uschSn);
                            edit.remove("imgurl3" + tcsn + uschSn);
                            edit.remove("imgurl4" + tcsn + uschSn);
                            edit.remove("format" + tcsn + uschSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + uschSn);
                            edit.remove("tag" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });
                } else if (code == 2) {

                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_layout, null);
                    TextView tv_message = (TextView) view
                            .findViewById(R.id.message);//输入内容
                    tv_message.setText("非常抱歉。系统正在进行维护，请您稍后再进行学习。");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    btn_cancel.setVisibility(View.GONE);
                    btn_sure.setText("确定");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            timer1.cancel();
                            timerTask = null;
                            timer1 = null;
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp1 = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            SharedPreferences.Editor edit = sp1.edit();
                            edit.remove("imgurl" + tcsn + uschSn);
                            edit.remove("imgurl1" + tcsn + uschSn);
                            edit.remove("imgurl2" + tcsn + uschSn);
                            edit.remove("imgurl3" + tcsn + uschSn);
                            edit.remove("imgurl4" + tcsn + uschSn);
                            edit.remove("format" + tcsn + uschSn);
                            edit.remove("firsttime" + tcsn);
                            edit.remove("num" + tcsn);
                            edit.remove("intfirsttime" + tcsn);
                            edit.remove("accessAudioUrl" + tcsn + uschSn);
                            edit.remove("tag" + tcsn);
                            edit.commit();
                            finish();
                        }
                    });
                } else if (code == 3) {
                    timerTask.cancel();
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("人脸识别失败,请面向镜头重新照相或者重新上传“我的”头像");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    btn_title.setVisibility(View.VISIBLE);
                    btn_cancel.setText("我的头像");
                    btn_message.setText("请确保拍照面部完整，五官清晰，如您多次人脸失败，请在“我的头像”中检查您的个人头像是否正常且且清晰。");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int stId = sp.getInt("stId", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("stId", stId);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });
                } else {
                    timerTask.cancel();
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
//                    TextView tv_message = (TextView) view
//                            .findViewById(R.id.message);//输入内容
//                    tv_message.setText("人脸识别失败,请面向镜头重新照相或者重新上传“我的”头像");
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    btn_title.setVisibility(View.VISIBLE);
                    btn_cancel.setText("我的头像");
                    btn_message.setText("请确保拍照面部完整，五官清晰，如您多次人脸失败，请在“我的”中检查您的个人头像是否正常且且清晰。");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int stId = sp.getInt("stId", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("stId", stId);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });
                }
            }
        } else {
            if (isphoto) {
                    if (tphotoMark == 1) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setWillNotDraw(false);
                        show_camera_iv.setContentDescription(messageurl);
                        Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                        show_camera_iv.setImageBitmap(bitmapByUrl);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, imgurl);
                        edit.commit();
                    } else if (tphotoMark == 2) {
                        le_course1.setVisibility(View.GONE);
                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            show_camera_iv.setWillNotDraw(false);
                            show_camera_iv.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            show_camera_iv1.setWillNotDraw(false);
                            show_camera_iv1.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv1.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                            edit.commit();
                        }
                    } else if (tphotoMark == 3) {
                        le_course1.setVisibility(View.GONE);
                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            show_camera_iv.setWillNotDraw(false);
                            show_camera_iv.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            show_camera_iv1.setWillNotDraw(false);
                            show_camera_iv1.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv1.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            show_camera_iv2.setWillNotDraw(false);
                            show_camera_iv2.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv2.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                            edit.commit();
                        }
                    } else if (tphotoMark == 4) {
                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv.setWillNotDraw(false);
                            show_camera_iv.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv1.setWillNotDraw(false);
                            show_camera_iv1.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv1.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv2.setWillNotDraw(false);
                            show_camera_iv2.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv2.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable() == null) {
                            le_course1.setVisibility(View.VISIBLE);
                            show_camera_iv3.setWillNotDraw(false);
                            show_camera_iv3.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv3.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl3" + tcsn + uschSn, imgurl);
                            edit.commit();
                        }
                    } else if (tphotoMark == 5) {
                        if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv.setWillNotDraw(false);
                            show_camera_iv.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv1.setWillNotDraw(false);
                            show_camera_iv1.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv1.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl1" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.GONE);
                            show_camera_iv2.setWillNotDraw(false);
                            show_camera_iv2.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv2.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl2" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.VISIBLE);
                            show_camera_iv3.setWillNotDraw(false);
                            show_camera_iv3.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv3.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl3" + tcsn + uschSn, imgurl);
                            edit.commit();
                        } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                            le_course1.setVisibility(View.VISIBLE);
                            show_camera_iv4.setWillNotDraw(false);
                            show_camera_iv4.setContentDescription(messageurl);
                            Bitmap bitmapByUrl = HelpUtil.getBitmapByUrl(messageurl);
                            show_camera_iv4.setImageBitmap(bitmapByUrl);
                            SharedPreferences.Editor edit = sp.edit();
                            edit.putString("imgurl4" + tcsn + uschSn, imgurl);
                            edit.commit();
                        }
                    }
            } else {
                if (tphotoMark == 1) {
                    le_course1.setVisibility(View.GONE);
                    show_camera_iv.setImageResource(R.mipmap.tongming);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("imgurl" + tcsn + uschSn, "");
                    edit.commit();
                    Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                } else if (tphotoMark == 2) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                } else if (tphotoMark == 3) {
                    le_course1.setVisibility(View.GONE);
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }

                } else if (tphotoMark == 4) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }

                } else if (tphotoMark == 5) {
                    if (show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv1.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl1" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.GONE);
                        show_camera_iv2.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl2" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv3.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl3" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    } else if (!show_camera_iv.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv1.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && !show_camera_iv2.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState()) && show_camera_iv3.getDrawable() != null && show_camera_iv4.getDrawable().getCurrent().getConstantState().equals(ContextCompat.getDrawable(LearnthemticlearningDetailsActivity.this, R.mipmap.tongming).getConstantState())) {
                        le_course1.setVisibility(View.VISIBLE);
                        show_camera_iv4.setImageResource(R.mipmap.tongming);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("imgurl4" + tcsn + uschSn, "");
                        edit.commit();
                        Toast.makeText(LearnthemticlearningDetailsActivity.this, "照片上传失败", Toast.LENGTH_LONG).show();
                    }
                }
            }
        }
    }

    private void showTakePhotoPopupWindow() {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        View view = View
                .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_photo_layout, null);
        LoginUserBean userInfo = UserManger.getUserInfo();
        String userId = userInfo.getData().getUserId();
        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                Context.MODE_PRIVATE);
        String photoUrl = sp.getString("photoUrl", "");
        ImageView img_photo = (ImageView) view.findViewById(R.id.img_photo2);
        if (!photoUrl.equals("")) {
            Picasso.with(LearnthemticlearningDetailsActivity.this).load(Uri.parse(photoUrl)).placeholder(R.mipmap.my_head).into(img_photo);//加载图片
        }
        TextView btn_PositiveButton = (TextView) view.findViewById(R.id.tv_photo6);//拍照
        TextView btn_NegativeButton = (TextView) view.findViewById(R.id.tv_photo5);//手机获取照片
        final AlertDialog dialog = builder.create();
        dialog.show();
        dialog.getWindow().setContentView(view);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setCancelable(false);
        btn_PositiveButton.setOnClickListener(new View.OnClickListener() {//拍照
            @Override
            public void onClick(View view) {
                LoginUserBean userInfo = UserManger.getUserInfo();
                String userId = userInfo.getData().getUserId();
                SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                        Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp.edit();
                int tcsn = sp.getInt("tcsn", 0);
                edit.putInt("tag" + tcsn, 1);
                edit.commit();
                startActivityForResult(TakePersonPictureActivity.class, null, 1);
                dialog.dismiss();


            }
        });

    }


    /*****
     * 接受第二个Activity返回的数据时调用
     *
     * ****/
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //  super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case 0://拍第一张返回
                if (resultCode == 1) {
                    if (data == null) {
                        return;
                    }
                    String url = data.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String stringTime = sp.getString("format" + tcsn + uschSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + uschSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 1) {

                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(0);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 2) {

                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(3);
                                    }
                                });
                                thread.start();


                            } else if (tphotoMark == 3) {

                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();


                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 1:
                if (resultCode == 1) {
                    final String url = data.getStringExtra("url");
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("photoUrl", url);
                    edit.commit();
                    AlertDialog.Builder builder = new AlertDialog.Builder(LearnthemticlearningDetailsActivity.this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    btn_title.setVisibility(View.INVISIBLE);
                    btn_message.setText("您已重新上传了个人头像，可点击“重新拍照”再次认证");
                    btn_cancel.setText("我的头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int stId = sp.getInt("stId", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("stId", stId);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });

                } else if (resultCode == 2) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(LearnthemticlearningDetailsActivity.this);
                    View view = View
                            .inflate(LearnthemticlearningDetailsActivity.this, R.layout.diolog_learn_person_layout, null);
                    TextView btn_sure = (TextView) view.findViewById(R.id.positiveButton);
                    TextView btn_cancel = (TextView) view.findViewById(R.id.negativeButton);
                    TextView btn_message = (TextView) view.findViewById(R.id.message);
                    TextView btn_title = (TextView) view.findViewById(R.id.title);
                    TextView btn_title1 = (TextView) view.findViewById(R.id.title1);
                    btn_title.setVisibility(View.INVISIBLE);
                    btn_title1.setText("请点我的头像！");
                    btn_message.setText("您上传了个人头像失败，可点击“我的头像”再次上传");
                    btn_cancel.setText("我的头像");
                    final AlertDialog dialog = builder.create();
                    dialog.show();
                    dialog.getWindow().setContentView(view);
                    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                    dialog.setCancelable(false);
                    btn_sure.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            LoginUserBean userInfo = UserManger.getUserInfo();
                            String userId = userInfo.getData().getUserId();
                            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                    Context.MODE_PRIVATE);
                            int stId = sp.getInt("stId", 0);
                            String photoUrl = sp.getString("photoUrl", "");
                            Bundle bundle = new Bundle();
                            bundle.putInt("stId", stId);
                            bundle.putString("photoUrl", photoUrl);
                            startActivityForResult(LearnthemticlearTakePhotoActivity.class, bundle, 0);

                        }
                    });
                    btn_cancel.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.dismiss();
                            showTakePhotoPopupWindow();
                        }
                    });

                }
                break;
            case 2:
                if (resultCode == 1) {
                    if (data == null) {
                        return;
                    }

                    String url = data.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String stringTime = sp.getString("format" + tcsn + uschSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + uschSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 2) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(3);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 3) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 3:
                if (resultCode == 1) {
                    if (data == null) {
                        return;
                    }

                    String url = data.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String stringTime = sp.getString("format" + tcsn + uschSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + uschSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 3) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(4);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 4:
                if (resultCode == 1) {
                    if (data == null) {
                        return;
                    }

                    String url = data.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String stringTime = sp.getString("format" + tcsn + uschSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + uschSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 4) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(5);
                                    }
                                });
                                thread.start();
                            } else if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
            case 5:
                if (resultCode == 1) {
                    if (data == null) {
                        return;
                    }

                    String url = data.getStringExtra("url");
                    if (url != null && !TextUtils.isEmpty(url)) {
                        LoginUserBean userInfo = UserManger.getUserInfo();
                        String userId = userInfo.getData().getUserId();
                        SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                                Context.MODE_PRIVATE);
                        int tcsn = sp.getInt("tcsn", 0);
                        int uschSn = sp.getInt("uschSn", 0);
                        String stringTime = sp.getString("format" + tcsn + uschSn, "");
                        int index1 = stringTime.indexOf(":");
                        int index2 = stringTime.indexOf(":", index1 + 1);
                        int hh = Integer.parseInt(stringTime.substring(0, index1));
                        int mi = Integer.parseInt(stringTime.substring(index1 + 1, index2));
                        int ss = Integer.parseInt(stringTime.substring(index2 + 1));
                        int formatTurnSecond = hh * 60 * 60 + mi * 60 + ss;
                        subformatTurnSecond = formatTurnSecond + 1;//处理拍照时延迟1秒
                        String stringTime1 = getStringTime(subformatTurnSecond);
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString("format" + tcsn + uschSn, stringTime1);
                        edit.putInt("tag" + tcsn, 1);
                        edit.commit();
                        int tphotoMark = sp.getInt("tphotoMark", 0);
                        int courseLength = sp.getInt("courseLength", 0);
                        if (subformatTurnSecond >= courseLength * 60) {
                            timerTask.cancel();
                        } else {
                            if (tphotoMark == 5) {
                                Thread thread = new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                                        mHandler.sendEmptyMessage(6);
                                    }
                                });
                                thread.start();
                            }
                        }
                    }
                }
                break;
        }


    }

    public class SpecifiedCourseDetailSubjectApt extends CommonAdapter<CourseDetailSubjectBean.RowsBean> {
        private final List<CourseDetailSubjectBean.RowsBean> mList;
        private Context context;

        private RadioButton radioButtonA;
        private RadioButton radioButtonB;
        private RadioButton radioButtonC;
        private RadioButton radioButtonD;
        private RadioButton radioButtonE;
        private RadioButton radioButtonF;
        private LiumRadioGroup radioGroup;

        private LinearLayout checkbox_ll;
        private CheckBox checkBoxA,checkBoxB,checkBoxC,checkBoxD,checkBoxE,checkBoxF;
        //  private HashMap<String,Boolean> states=new HashMap<String,Boolean>();//记录所有radiobutton被点击的状态


        public SpecifiedCourseDetailSubjectApt(Context context, List<CourseDetailSubjectBean.RowsBean> mList, int itemLayoutId) {
            super(context, mList, itemLayoutId);
            this.context = context;
            this.mList = mList;


        }

        @Override
        public void convert(ViewHolder holder, final CourseDetailSubjectBean.RowsBean item, final int position) {
            TextView tv_course_title = holder.getView(R.id.tv_course2);
            ImageView img_course_img = holder.getView(R.id.img_course_item);
            tv_course_title.setText(position + 1 + ". " + mList.get(position).getQuestionDesc());


            if (mList.get(position).getUrl() == null) {
                img_course_img.setVisibility(View.GONE);

            } else {
                img_course_img.setVisibility(View.VISIBLE);

                if (mList.get(position).getUrl().contains("aliyuncs.com")) {
                    Picasso.with(context).load(Uri.parse(mList.get(position).getUrl())).placeholder(R.mipmap.no_data2).into(img_course_img);
                } else {

                    Picasso.with(context).load(Uri.parse(AppInterfaceConfig.getRequestUrl(mList.get(position).getUrl()))).placeholder(R.mipmap.no_data2).into(img_course_img);
                }
            }


            /*LiumRadioGroup radioGroup = (LiumRadioGroup) holder.getView(R.id.course_rg);
            RadioButton radioButtonA = (RadioButton) radioGroup.findViewById(R.id.radioButton_course);
            RadioButton radioButtonB = (RadioButton) radioGroup.findViewById(R.id.radioButton_course1);
            RadioButton radioButtonC = (RadioButton) radioGroup.findViewById(R.id.radioButton_course2);
            RadioButton radioButtonD = (RadioButton) radioGroup.findViewById(R.id.radioButton_course3);*/

            checkbox_ll = (LinearLayout) holder.getView(R.id.checkbox_ll);
            checkBoxA=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course0);
            checkBoxB=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course1);
            checkBoxC=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course2);
            checkBoxD=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course3);
            checkBoxE=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course4);
            checkBoxF=(CheckBox)checkbox_ll.findViewById(R.id.checkbox_course5);
            radioGroup = (LiumRadioGroup) holder.getView(R.id.course_rg);
            radioButtonA = (RadioButton) radioGroup.findViewById(R.id.radioButton_course);
            radioButtonB = (RadioButton) radioGroup.findViewById(R.id.radioButton_course1);
            radioButtonC = (RadioButton) radioGroup.findViewById(R.id.radioButton_course2);
            radioButtonD = (RadioButton) radioGroup.findViewById(R.id.radioButton_course3);
            radioButtonE = (RadioButton) radioGroup.findViewById(R.id.radioButton_course4);
            radioButtonF = (RadioButton) radioGroup.findViewById(R.id.radioButton_course5);

            CheckBox[] checkBoxs=new CheckBox[]{checkBoxA,checkBoxB,checkBoxC,checkBoxD,checkBoxE,checkBoxF};
            RadioButton[] radioButtons=new RadioButton[]{radioButtonA,radioButtonB,radioButtonC,radioButtonD,radioButtonE,radioButtonF};
            String[] options=new String[]{mList.get(position).getOptionA(),mList.get(position).getOptionB(),mList.get(position).getOptionC(),mList.get(position).getOptionD(),mList.get(position).getOptionE(),mList.get(position).getOptionF()};
            String[] numLables=new String[]{"A","B","C","D","E","F"};

            if(mList.get(position).getqType()==2){
                checkbox_ll.setVisibility(View.VISIBLE);
                radioGroup.setVisibility(View.GONE);
                buttonShow(checkBoxs,options,numLables);
            }else{
                checkbox_ll.setVisibility(View.GONE);
                radioGroup.setVisibility(View.VISIBLE);
                buttonShow(radioButtons,options,numLables);
            }

            List<String> answers=new ArrayList<>();
            for(int i=0;i<checkBoxs.length;i++){
                int finalI = i;
                checkBoxs[i].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if(!checkBoxs[finalI].isChecked()){
                            answers.remove(numLables[finalI]);
                            if(answers.size()<=0){
                                item.setSelect(false);//是否选择
                            }
                        }else{
                            item.setSelect(true);
                            answers.add(numLables[finalI]);
                        }
                        LogUtils.e("测试", "LearnthemticlearningDetailsActivity: "+listToStr(answers) );
                        //判断答案是否正确
                        if(mList.get(position).getRightOption().equals(listToStr(answers))){
                            item.setLOOP(true);
                        }else{
                            item.setLOOP(false);
                        }
                    }
                });
            }


            /*if (mList.get(position).getOptionA() == null) {
                radioButtonA.setVisibility(View.GONE);

            } else {
                radioButtonA.setVisibility(View.VISIBLE);
                radioButtonA.setText("A." + mList.get(position).getOptionA());
            }
            if (mList.get(position).getOptionB() == null) {
                radioButtonB.setVisibility(View.GONE);

            } else {
                radioButtonB.setVisibility(View.VISIBLE);
                radioButtonB.setText("B." + mList.get(position).getOptionB());
            }

            if (mList.get(position).getOptionC() == null) {
                radioButtonC.setVisibility(View.GONE);

            } else {
                radioButtonC.setVisibility(View.VISIBLE);
                radioButtonC.setText("C." + mList.get(position).getOptionC());
            }
            if (mList.get(position).getOptionD() == null) {
                radioButtonD.setVisibility(View.GONE);

            } else {
                radioButtonD.setVisibility(View.VISIBLE);
                radioButtonD.setText("D." + mList.get(position).getOptionD());
            }*/

            LoginUserBean userInfo = UserManger.getUserInfo();
            String userId = userInfo.getData().getUserId();
            SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                    Context.MODE_PRIVATE);
            int apromptMark = sp.getInt("apromptMark", 0);
            radioGroup.setOnCheckedChangeListener(null);
            switch (item.getChecked()) {
                case 1:
                    radioGroup.check(R.id.radioButton_course);
                    String right_A = mList.get(position).getRightOption();
                    if ("A".equals(right_A)) {
                        item.setLOOP(true);
                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {

                            if (right_A.equals("B")) {
                                radioButtonB.startAnimation(animation);
                            } else if (right_A.equals("C")) {
                                radioButtonC.startAnimation(animation);
                            } else if (right_A.equals("D")) {
                                radioButtonD.startAnimation(animation);
                            }else if (right_A.equals("E")) {
                                radioButtonE.startAnimation(animation);
                            }else if (right_A.equals("F")) {
                                radioButtonF.startAnimation(animation);
                            }
                        }
                    }
                    break;
                case 2:
                    radioGroup.check(R.id.radioButton_course1);
                    String right_B = mList.get(position).getRightOption();
                    if ("B".equals(right_B)) {
                        item.setLOOP(true);

                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {
                            if (right_B.equals("A")) {
                                radioButtonA.startAnimation(animation);

                            } else if (right_B.equals("C")) {
                                radioButtonC.startAnimation(animation);
                            } else if (right_B.equals("D")) {
                                radioButtonD.startAnimation(animation);
                            }else if (right_B.equals("E")) {
                                radioButtonE.startAnimation(animation);
                            }else if (right_B.equals("F")) {
                                radioButtonF.startAnimation(animation);
                            }
                        }
                    }


                    break;
                case 3:
                    radioGroup.check(R.id.radioButton_course2);
                    String right_C = mList.get(position).getRightOption();
                    if ("C".equals(right_C)) {
                        item.setLOOP(true);

                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {
                            if (right_C.equals("A")) {
                                radioButtonA.startAnimation(animation);

                            } else if (right_C.equals("B")) {
                                radioButtonB.startAnimation(animation);
                            } else if (right_C.equals("D")) {
                                radioButtonD.startAnimation(animation);
                            }else if (right_C.equals("E")) {
                                radioButtonE.startAnimation(animation);
                            }else if (right_C.equals("F")) {
                                radioButtonF.startAnimation(animation);
                            }
                        }
                    }
                    break;
                case 4:
                    radioGroup.check(R.id.radioButton_course3);
                    String right_D = mList.get(position).getRightOption();
                    if ("D".equals(right_D)) {
                        item.setLOOP(true);
                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {
                            if (right_D.equals("A")) {
                                radioButtonA.startAnimation(animation);
                            } else if (right_D.equals("B")) {
                                radioButtonB.startAnimation(animation);
                            } else if (right_D.equals("C")) {
                                radioButtonC.startAnimation(animation);
                            }else if (right_D.equals("E")) {
                                radioButtonE.startAnimation(animation);
                            }else if (right_D.equals("F")) {
                                radioButtonF.startAnimation(animation);
                            }
                        }
                    }
                    break;
                case 5:
                    radioGroup.check(R.id.radioButton_course3);
                    String right_E = mList.get(position).getRightOption();
                    if ("E".equals(right_E)) {
                        item.setLOOP(true);
                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {
                            if (right_E.equals("A")) {
                                radioButtonA.startAnimation(animation);
                            } else if (right_E.equals("B")) {
                                radioButtonB.startAnimation(animation);
                            } else if (right_E.equals("C")) {
                                radioButtonC.startAnimation(animation);
                            }else if (right_E.equals("D")) {
                                radioButtonD.startAnimation(animation);
                            }else if (right_E.equals("F")) {
                                radioButtonF.startAnimation(animation);
                            }
                        }
                    }
                    break;
                case 6:
                    radioGroup.check(R.id.radioButton_course3);
                    String right_F = mList.get(position).getRightOption();
                    if ("F".equals(right_F)) {
                        item.setLOOP(true);
                    } else {
                        item.setLOOP(false);
                        if (apromptMark == 1) {
                            if (right_F.equals("A")) {
                                radioButtonA.startAnimation(animation);
                            } else if (right_F.equals("B")) {
                                radioButtonB.startAnimation(animation);
                            } else if (right_F.equals("C")) {
                                radioButtonC.startAnimation(animation);
                            }else if (right_F.equals("D")) {
                                radioButtonD.startAnimation(animation);
                            }else if (right_F.equals("E")) {
                                radioButtonE.startAnimation(animation);
                            }
                        }
                    }
                    break;
                default:
                    radioGroup.clearCheck();
                    break;
            }
            radioGroup.setId(position);
            radioGroup.setOnCheckedChangeListener(new LiumRadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(LiumRadioGroup group, int checkedId) {
                    item.setSelect(true);
                    LoginUserBean userInfo = UserManger.getUserInfo();
                    String userId = userInfo.getData().getUserId();
                    SharedPreferences sp = getSharedPreferences("LearnthemticlearningDetailsActivity" + userId,
                            Context.MODE_PRIVATE);
                    int apromptMark = sp.getInt("apromptMark", 0);
                    if (checkedId == R.id.radioButton_course) {//                            if(formattime < num)
//                            {
//                                radioButtonA.setChecked(false);
//                                TiShiDialog.Builder builder1 = new TiShiDialog.Builder(context);
//                                builder1.setMessage("学习时间不足，暂不能答题。");
//                                builder1.setTitle("提示:");
//                                builder1.setPositiveButton("继续学习", new DialogInterface.OnClickListener() {
//                                    public void onClick(DialogInterface dialog, int which) {
//                                        dialog.dismiss();;
//                                        //设置你的操作事项
//                                    }
//                                });
//                                builder1.create().show();
//
//
//                                return;
//                            }

                        //                          radioButtonA.setChecked(true);
                        mList.get(position).setChecked(1);
                        String right_A = mList.get(position).getRightOption();
                        if ("A".equals(right_A)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_A.equals("B")) {
                                    radioButtonB.startAnimation(animation);
                                } else if (right_A.equals("C")) {
                                    radioButtonC.startAnimation(animation);
                                } else if (right_A.equals("D")) {
                                    radioButtonD.startAnimation(animation);
                                } else if (right_A.equals("E")) {
                                    radioButtonE.startAnimation(animation);
                                } else if (right_A.equals("F")) {
                                    radioButtonF.startAnimation(animation);
                                }
                            }

                        }
                    } else if (checkedId == R.id.radioButton_course1) {
                        mList.get(position).setChecked(2);
                        String right_B = mList.get(position).getRightOption();
                        if ("B".equals(right_B)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_B.equals("A")) {
                                    radioButtonA.startAnimation(animation);
                                } else if (right_B.equals("C")) {
                                    radioButtonC.startAnimation(animation);
                                } else if (right_B.equals("D")) {
                                    radioButtonD.startAnimation(animation);
                                } else if (right_B.equals("E")) {
                                    radioButtonE.startAnimation(animation);
                                } else if (right_B.equals("F")) {
                                    radioButtonF.startAnimation(animation);
                                }
                            }
                        }
                    } else if (checkedId == R.id.radioButton_course2) {
                        mList.get(position).setChecked(3);
                        String right_C = mList.get(position).getRightOption();
                        if ("C".equals(right_C)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_C.equals("A")) {
                                    radioButtonA.startAnimation(animation);

                                } else if (right_C.equals("B")) {
                                    radioButtonB.startAnimation(animation);
                                } else if (right_C.equals("D")) {
                                    radioButtonD.startAnimation(animation);
                                } else if (right_C.equals("E")) {
                                    radioButtonE.startAnimation(animation);
                                } else if (right_C.equals("F")) {
                                    radioButtonF.startAnimation(animation);
                                }
                            }
                        }
                    } else if (checkedId == R.id.radioButton_course3) {
                        mList.get(position).setChecked(4);
                        String right_D = mList.get(position).getRightOption();
                        if ("D".equals(right_D)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_D.equals("A")) {
                                    radioButtonA.startAnimation(animation);

                                } else if (right_D.equals("B")) {
                                    radioButtonB.startAnimation(animation);
                                } else if (right_D.equals("C")) {
                                    radioButtonC.startAnimation(animation);
                                } else if (right_D.equals("E")) {
                                    radioButtonE.startAnimation(animation);
                                } else if (right_D.equals("F")) {
                                    radioButtonF.startAnimation(animation);
                                }
                            }
                        }
                    } else if (checkedId == R.id.radioButton_course4) {
                        mList.get(position).setChecked(5);
                        String right_E = mList.get(position).getRightOption();
                        if ("E".equals(right_E)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_E.equals("A")) {
                                    radioButtonA.startAnimation(animation);
                                } else if (right_E.equals("B")) {
                                    radioButtonB.startAnimation(animation);
                                } else if (right_E.equals("C")) {
                                    radioButtonC.startAnimation(animation);
                                } else if (right_E.equals("D")) {
                                    radioButtonD.startAnimation(animation);
                                } else if (right_E.equals("F")) {
                                    radioButtonF.startAnimation(animation);
                                }
                            }
                        }
                    } else if (checkedId == R.id.radioButton_course5) {
                        mList.get(position).setChecked(6);
                        String right_F = mList.get(position).getRightOption();
                        if ("F".equals(right_F)) {
                            item.setLOOP(true);
                        } else {
                            item.setLOOP(false);
                            if (apromptMark == 1) {
                                if (right_F.equals("A")) {
                                    radioButtonA.startAnimation(animation);
                                } else if (right_F.equals("B")) {
                                    radioButtonB.startAnimation(animation);
                                } else if (right_F.equals("C")) {
                                    radioButtonC.startAnimation(animation);
                                } else if (right_F.equals("D")) {
                                    radioButtonD.startAnimation(animation);
                                } else if (right_F.equals("E")) {
                                    radioButtonE.startAnimation(animation);
                                }
                            }
                        }
                    }


                }
            });
        }


        private void buttonShow(Button[] buttons, String[] options, String[] labels) {
            for(int i=0;i<buttons.length;i++){
                if (options[i] == null || options[i].equals("")) {
                    buttons[i].setVisibility(View.GONE);
                } else {
                    buttons[i].setVisibility(View.VISIBLE);
                    buttons[i].setText(labels[i] + options[i]);
                }
            }
        }

        private String listToStr(List<String> lists){
            Collections.sort(lists);
            String str="";
            for(int i=0;i<lists.size();i++){
                str+=lists.get(i);
            }
            return str;
        }
    }

    private void userStCourseSave(Integer uschSn, Integer sn, Integer tcSn, Integer readLength, Integer mark, String mac, Integer stId, List<UserTcPhoto> photoList, int what){
        /*if(stId== 510016 || stId== 510017 || stId== 510018 || stId== 510019){  //四川专题
            if(mark==0){ //未完成
                HelpUtil.showTiShiDialog(LearnthemticlearningDetailsActivity.this,"课程未学完暂不能提交");
                if(mProgressDialog!=null){
                    mProgressDialog.cancel();
                }
                return;
            }else if(mark==1){
                new Login().getSureSpeciedcourse(uschSn, sn, tcSn, readLength, mark,mac,stId, photoList, LearnthemticlearningDetailsActivity.this, what);
            }
        }else{
            new Login().getSureSpeciedcourse(uschSn, sn, tcSn, readLength, mark,mac,stId, photoList, LearnthemticlearningDetailsActivity.this, what);
        }*/
        new Login().getSureSpeciedcourse(uschSn, sn, tcSn, readLength, mark,mac,stId, photoList, LearnthemticlearningDetailsActivity.this, what);
    }


    private boolean forbidHourJudge(){
        boolean canStudy=false;

        int time1=Integer.valueOf(forbidHour.split(",")[0]);
        int time2=Integer.valueOf(forbidHour.split(",")[1]);
        int nowHour=new Date().getHours();
        if(time1<time2){ //2-5
            if(nowHour>=time1 && nowHour<=(time2-1)){
                canStudy=false;
            }else{
                canStudy=true;
            }
        }else{
            if(nowHour>=time2 && nowHour<=(time1-1)){
                canStudy=true;
            }else{
                canStudy=false;
            }
        }
        return canStudy;
    }


    private void showAlertDialog(SuperFileView2 superFileView2, String url) {
        //1、使用Dialog、设置style
        //2、设置布局

        View contentView = LayoutInflater.from(LearnthemticlearningDetailsActivity.this).inflate(R.layout.dialog_circle, null);
        mDownloadPopWindow = new PopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);

        mDownloadPopWindow.setContentView(contentView);
        mDownloadPopWindow.setFocusable(false);
        mDownloadPopWindow.setOutsideTouchable(false);
        mDownloadPopWindow.showAtLocation(contentView, Gravity.CENTER, 0, 0);


        CircularProgressView circularProgressView = contentView.findViewById(R.id.circleProgress);
        TextView textView = contentView.findViewById(R.id.progressTxt);
        TextView textView1 = contentView.findViewById(R.id.hintTxt);

        jumpingBeans2 = JumpingBeans.with(textView1)
                .makeTextJump(0, textView1.getText().length())
                .setIsWave(true)
                .setLoopDuration(3000)
                .build();

        downLoadFromNet(url, superFileView2, circularProgressView, textView);
    }

    private void downLoadFromNet(final String url, final SuperFileView2 superFileView, CircularProgressView circularProgressView, TextView tv1) {
        //showLoadingDialog("文件下载中...");
        //1.网络下载、存储路径、
        File cacheFile = FileParseUtil.getCacheFile(url);
        if (cacheFile.exists()) {
            if (cacheFile.length() <= 0) {
                cacheFile.delete();
                return;
            }
        }

        OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(20, TimeUnit.SECONDS).readTimeout(20, TimeUnit.SECONDS).build();
        Request request = new Request.Builder().get().url(url).build();
        okHttpClient.newCall(request).enqueue(new okhttp3.Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                //请求成功,从服务器的响应对象中获取apk,流(服务器 输入流(提供数据)  本地 输出流(写入文件))
                ResponseBody body = response.body();
                //告知progressDialog总进度,不变
                //progressDialog.setMax((int) body.contentLength());
                final int allLength = (int) body.contentLength();
                //inputStream就是服务器把需要下载的apk以流的形式提供给客户端
                InputStream inputStream = body.byteStream();

                String fileName = url.substring(url.lastIndexOf("/"));
                String directory = Environment.getExternalStoragePublicDirectory
                        (Environment.DIRECTORY_DOWNLOADS).getPath();
                //File file = new File(directory+fileName);

                File file = FileParseUtil.getCacheFile(url);
                FileOutputStream fos = new FileOutputStream(file);
                byte[] bytes = new byte[1024];
                int len = 0;
                int temp = 0;//用于记录目前下载的到的位置
                while ((len = inputStream.read(bytes)) != -1) {
                    //将读过的数据写入文件中
                    fos.write(bytes, 0, len);
                    //告知progressDialog在下载过程中的当前进度
                    temp += len;
                    //将当前的下载位置,设置给progressDialog
                    //progressDialog.setProgress(temp);
                    //没下载一段数据,睡眠一段时间

                    int progress = (int) (temp * 100.0 / allLength);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            circularProgressView.setProgress(progress);
                            tv1.setText(progress + "%");
                        }
                    });

                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        //2.ACache记录文件的有效期
                        mDownloadPopWindow.dismiss();
                        superFileView.displayFile(file);
                    }
                });
            }
        });
    }
}